php接收数据:
<?php
$dat=file_get_contents('php://input','r');
//....
echo $dat;
?>c++模拟:数据头:
POST / HTTP/1.1\r\nContent-Length: 14\r\nContent-Type: application/octet-stream\r\nHost: xx.xx.xx.xx:7200\r\n\r\n二进制数据:
0x7e, 0xff, 0x13, 0x66, 0x26, 0x13, 0x95, 0x9f,0xff, 0xff, 0x00, 0xf4, 0x91, 0x7e注意:如果红色的0x00为非0x00的数据,比如0x01,则一切正常,为0x00空字节后,则php卡住,超时30多秒后才返回内容。请问:
数据头是否对? 或者发送的二进制数据要经过编码什么的? 为何卡住?

解决方案 »

  1.   

    既然是用PHP来做服务端,为什么还要用C++的服务方式来写?
    按下面的来:
    <?php
    $dat=$_POST["dataname"];
    //....
    echo $dat;
    ?>C++发送数据头POST / HTTP/1.1\r\nContent-Length: 14\r\nContent-Type: application/octet-stream\r\nHost: xx.xx.xx.xx:7200\r\n\r\n
    dataname=需要发送的数据,最好用URL编码
      

  2.   

    post的数据应该是key=value的形式你把2进制数据转为这种形式的string发上去,就不卡了