Re: problem while reading on sockets ...

From: Date: Fri, 27 Jul 2001 01:35:34 +0000
Subject: Re: problem while reading on sockets ...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59854@lists.php.net to get a copy of this message
On Thu, 26 Jul 2001 23:43, Arnauld Dravet - smurfie wrote: > Hello, > > simple question: > > $sock = fsockopen($server_ip, $server_port, $errno, $errstr, 30); > while(!feof($sock)) echo fgets($sock,4096); > fclose($sock); > > why does the while() makes an infinite loop, like if FEOF was never > found ? what is the character used to tell if there's an EOF or not ? > could my problem come from the server i'm connecting to which to not > send a "legit" string ? > > thanks > > Arnauld Dravet > smurfie@artefact21.net Not having done this, but wouldn't you need to send a GET to the server to have it return something? At least that seems to be what the example in the manual does. $fp = fsockopen ("www.php.net", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br>\n"; } else { fputs ($fp, "GET / HTTP/1.0\r\n\r\n"); while (!feof($fp)) { echo fgets ($fp,128); } fclose ($fp); } -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Cause of crash: Inadvertent contact with the ground.

« previous php.general (#59854) next »