Issues with socket connections using fread/fgets on Linux
| From: | Perry Loh | Date: | Wed, 06 Sep 2000 05:25:16 +0000 |
| Subject: | Issues with socket connections using fread/fgets on Linux | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-15443@lists.php.net to get a copy of this message | ||
I'm running PHP4.0.1pl2 off RedHat Linux. I'm trying to connect to a server
via socket using pfsockopen and then sending data with fwrite/fputs. There
seems to be no problem sending data out, but when it comes to trying to
retrieve data back from the socket via fread/fgets, the script just stalls
there.
Has anyone faced a similar issue ?
I've tried a simple script below just to test whether it works from the
server, but seems to fail, although it works on IIS(Win32 ).
$fp = fsockopen("www.php.net", 80, &$errno, &$errstr, 30);
if(!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs($fp,"GET / HTTP/1.0\n\n");
while(!feof($fp)) {
echo fgets($fp,128);
}
fclose($fp);
}