doujiu8479 2013-12-03 21:46
浏览 36
已采纳

使用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);

  • 写回答

1条回答 默认 最新

  • dongzhimeng2464 2013-12-03 22:16
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?