I am reading binary data from a network socket in PHP. With files, you can use the 'b' mode to specify that the file is binary and should be read as such, but how does one mark a network socket as being binary?
问问题
409 次
I am reading binary data from a network socket in PHP. With files, you can use the 'b' mode to specify that the file is binary and should be read as such, but how does one mark a network socket as being binary?
网络套接字总是被假定为二进制数据,所以这个标志不是必需的。基于文件的操作的标志的“二进制”名称选择得有些糟糕。它应该是“不翻译行尾字符”标志。
否则,显而易见的读数是,如果您不指定b
,则应以模拟模式读取文件。
使用unpack()
是 php 如何读取二进制数据。
//example:
$un = unpack("V",$some_bin_string);