使用socket_read

PHP documetation http://www.php.net/manual/en/function.socket-read.php says

" length The maximum number of bytes read is specified by the length parameter. Otherwise you can use , , or \0 to end reading (depending on the type parameter, see below). "

Can you please explain this "Otherwise" I need to read several portions from an application. Each portion is ending with \0 Still can't get it...

EDIT: That is how I tried to apply it: $bytes = socket_read($socket, 2048, PHP_NORMAL_READ);

The function reads from the socket for length of bytes or it will stop reading early if type argument is:

  • PHP_BINARY_READ (default) then will stop reading at \0.
  • PHP_NORMAL_READ then will stop reading at or .

Appears what you are looking for is the default binary read instead of normal.