I need to unpack a response from a server that has a packed 4byte integer, which indicates the length of the response. I don't even know how to trouble shoot, since I have no access to the server. Basically, the leading byte is off somehow. The following gives me a byte of 0 first, then distorted where it is not accurate.
$size_get=fgets($fp, 4);
$size=unpack('N',$size_get);
echo fgets($fp, $size[1]) . PHP_EOL;
ANSWERED PART:
I'm using a socket connection and the provider is asking that I pack the length of the message, into the beginning of the message, as a 4byte integer. They arent familiar with php, so stackoverflow is my go-to. I searched but nothing really comes up.
$message='{login:"username";pass:"password"}';
$length=pack("N",strlen($message));
fwrite($connection, $length.$message);
I'm using stream_socket_client().