Re: problem while reading on sockets ...

From: Date: Fri, 27 Jul 2001 08:42:46 +0000
Subject: Re: problem while reading on sockets ...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-59898@lists.php.net to get a copy of this message
well because i'm not connecting to a web server ... ----- Original Message ----- From: "David Robley" <huntsman@www.nisu.flinders.edu.au> To: "Arnauld Dravet - smurfie" <smurfie@artefact21.net>; <php-general@lists.php.net> Sent: Friday, July 27, 2001 3:35 AM Subject: Re: [PHP] problem while reading on sockets ... > 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 (#59898) next »