Re: fgets() hang up?

From: Date: Wed, 29 Nov 2000 03:45:42 +0000
Subject: Re: fgets() hang up?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-27727@lists.php.net to get a copy of this message
Could you suggest how I would go about using "timing"? I'm not sure how to make a socket just "wait". Thanks for your response :o) -- Jon ----- Original Message ----- From: "Richard Lynch" <richard@zend.com> To: <php-general@lists.php.net> Sent: Tuesday, November 28, 2000 2:56 PM Subject: Re: [PHP] fgets() hang up? > It's up to you to do some timing and data anticipation when working with > sockets. > > If you get feof(), it's usually because the socket closed abnormally, I > think. > > ----- Original Message ----- > From: Jon <apostolj@mail.lafayette.edu> > Newsgroups: php.general > Sent: Tuesday, November 28, 2000 10:29 AM > Subject: [PHP] fgets() hang up? > > > > When using a persistant connection, why does this code hang up on the > > fifth loop iteration (the socket connected to only returns four lines, > > so obviously its not quitting the loop when it should) > > > > // defined earlier on in the class: > > > > var $socket; // this is set and connected to when the object > > // is created (pfsockopen / fsockopen ) > > > > function readAll() > > { > > > > $returnData = Array(); > > > > while ( !feof( $this->socket ) ) > > { > > echo "."; > > flush(); > > $thisLine = fgets( $this->socket, 128 ); > > if ( $thisLine != "" ) > > $returnData[] = $thisLine; > > else break; > > } > > > > return $returnData; > > } > > > > // The socket is connecting, cause if I loop 4 times specifically, it > > // works fine.. it gets caught up on the fifth line.. > > // the echo "." /flush() is simply for me to see where it's getting > > // caught > > > > Thanks! -- Jon > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#27727) next »