How can I send data to a listening Terminal ?!?! (see task)
Szenario is:
I have a terminal that is listening on a IP:PORT e.g. 192.168.1.100:12345
I create a socket and connect like
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$result = socket_connect($socket, $host, $port);
Now I want to write data to the socket. The data i have looks like:
0x06 0x01 0x07 0x04 0x00 0x00 0x00 0x00 0x00 0x69
actually the terminal should show up 0.69 cent
in the display. But i need to send the data infront of the 0x69
too.
I'm sending the Data like
socket_write($socket, $data, strlen($data));
I have read some about a php pack()
function and tried this...
$data = pack( "C", "\x06\x01\x07\x04\x00\x00\x00\x00\x00\x69" );
what i have also tried is
$data = pack("c","\x06\x01\x07\x04\x00\x00\x00\x00\x00\x69");//nothing happens
$data = "0x06 0x01 0x07 0x04 0x00 0x00 0x00 0x00 0x00 0x69";//nothing happens
but this doesn't do the thing.
I friend of mine worte a programm in c++ and it works easy.
TASK
Task is to send data in 8bit format and as hex.
EDIT