How to write byte by byte to socket in PHP?
byte, php, raw-sockets, sockets
Solution
You can use the pack function to pack the data into any datatype you wish. Then send it with any of the socket functions.
$strLen = strlen($msg);
$packet = pack("a{$strLen}C7", $msg, 14, 56, 255, 11, 7, 89, 152);
$pckLen = strlen($packet);
socket_write($socket, $packet, $pckLen);
Problem
How to write byte by byte to socket in PHP? For example how can I do something like: ``` socket_write($socket,$msg.14.56.255.11.7.89.152,strlen($msg)+7); ``` The pseudo code concatenated digits are actually bytes in dec. Hope you understand me.