hi all,
i need to know how do i detect NULL-termination of a NULL-terminated stream sent to my machine over a socket connection open with pfsockopen();
$fp = pfsockopen("tcp://xx.xx.xx.xx", 99999, $errno, $errstr,15);
if (!$fp) {
echo "ERROR: $errno - $errstr<br>\n";
} else {
stream_set_timeout($fp, 5);
fwrite($fp,$xml."\0");
echo fread($fp, 128);
fclose($fp);
}
the code above kinda works because i have set the stream_set_timeout myself. if that line is commented out i get back the result after the connection times out. which is a few minutes. i'd like the connection to be ended after i get the NULL-termination of the file (immediately). feof() doesn't work for this...
above where you see $xml."" is actually $xml."\0" - the \0 is the NULL-termination i have to send when i do the request - and that's the one i have to detect when i get the response...