开发者

Setting binmode on PHP sockets

I am reading binary开发者_如何学Go 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?


Network sockets are always assumed to be binary data, so the flag's not necessary. The "binary" name for the flag on file-based operations is somewhat badly chosen. It should be the "do not translate line-ending characters" flag.

Otherwise the obvious reading would be that if you don't specify b, the file should be read in analog mode.


Using unpack() is how php read binary data.

//example:
$un = unpack("V",$some_bin_string);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜