I need to post some data to the listening serwer and get answear using sockets in php.
Putting work fine (receiver get what he needs), but when I try to get any serwer answear I just cant. It just goes over and over and over... looks like while
never ends but why? (on the serwer side team check and say that responce is submitet to me).
I use Php but serwer is c++ (I heard this might be the problem)
The code:
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);
}
I used 3 different ways in php to open socket and they all seem to have similar issue. How can I test what is going wrong?