If I open a connection to an SMTP server and send out commands via fwrite() to a handle opened by fsockopen() I can read the results using fgets() on the handle. Good.
This is working fine for reading back a single line in a response but when attempting the following the script just hangs.
Code: Select all
$data = "";
while (!feof($handle))
{
$data .= fgets($handle);
}
echo $data;On a response that through telnet I saw 5 lines returned I manually wrote code to run fgets() 5 times on the handle and it worked.... when running it for a 6th time the script hangs like before.
I've tried stream_get_contents() and this has the same outcome. Has anybody got any experience of working out how many times fgets() needs to be called? Is it even anything to do with the EOF?
Cheers.