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.

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

报告相同问题?

悬赏问题

  • ¥30 关于#java#的问题,请各位专家解答!
  • ¥30 vue+element根据数据循环生成多个table,如何实现最后一列 平均分合并
  • ¥20 pcf8563时钟芯片不启振
  • ¥20 pip2.40更新pip2.43时报错
  • ¥15 换yum源但仍然用不了httpd
  • ¥50 C# 使用DEVMOD设置打印机首选项
  • ¥15 麒麟V10 arm安装gdal
  • ¥20 OPENVPN连接问题
  • ¥15 flask实现搜索框访问数据库
  • ¥15 mrk3399刷完安卓11后投屏调试只能显示一个设备