Php字符串不会在socket_recv中使用扩展的ascii [英] Php string does not take extended ascii in socket_recv

查看:147
本文介绍了Php字符串不会在socket_recv中使用扩展的ascii的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have an application where I am receiving data using socket_recv. The data received varies from 07 to ff of hex which i am storing in string. the problem is i am getting data like 3f in hex when i should receive ff. which means the problem is with sign bit. below is the example code




if(socket_recv ( $sock , $str , 6 , MSG_DONTWAIT ) === FALSE)
{
    $errorcode = socket_last_error();
    $errormsg = socket_strerror($errorcode);

    die("Could not receive data: [$errorcode] $errormsg \n");
}





我的尝试:



我尝试以各种方式显示接收的数据,并显示接收数据的十进制,十六进制等效值。不确定我是否没有正确接收或显示。



What I have tried:

I have tried displaying the received data in all ways and also displaying decimal,hex equivalent of received data. not sure whether i am not receiving properly or displaying.

推荐答案

sock ,
sock ,


str , 6 ,MSG_DONTWAIT)=== FALSE)
{
str , 6 , MSG_DONTWAIT ) === FALSE) {


errorcode = socket_last_error();
errorcode = socket_last_error();


这篇关于Php字符串不会在socket_recv中使用扩展的ascii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆