我需要将一些数据发布到监听服务器并使用 php 中的套接字获取答案。
把工作做好(接收者得到他需要的东西),但是当我试图得到任何 serwer answear 时,我就是不能。它只是一遍又一遍……看起来while
永远不会结束,但为什么呢?(在服务器端团队检查并说响应是提交给我的)。
我使用 Php 但 serwer 是 c++(我听说这可能是问题所在)
编码:
ini_set('max_execution_time', 36000); // to test the shile for a longer time, but aparentry responce goes right away
$fp = fsockopen("192.168.x.x", 9999, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
echo "Connected<br />\n";
$out = chr(11)."MSH|....some fields there....|".chr(28).chr(13); //chr(x) are ruquired by serwer
if ( fputs($fp, $out, strlen($out)) )
{
echo "<br />\nwriting message<br />\n";//if I eomment the while below this will show without problem
while (!feof($fp)) {
echo fgets($fp, 1024);
}//just goes and goes... never finding end of file (I gues)
}
fclose($fp);
}
我在 php 中使用了 3 种不同的方式来打开套接字,它们似乎都有类似的问题。我如何测试出了什么问题?