slow reading from socket
| From: | Mike | Date: | Thu, 25 Jul 2002 23:33:47 +0000 |
| Subject: | slow reading from socket | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-109629@lists.php.net to get a copy of this message | ||
Hi
I am building (or attemting to build) an msn messenger class. I am having
problems reading from the socket.
I open a connection with fsockopen(), i then write commands to the socket
with fputs(). I am reading wth fgets().
It is all fine if I am reading one line returned by the server, the script
runs quickly. However is i wish to read multiple lines the script basically
stops. I am working with code like this to read multiple lines...
<?php
function read() {
$fp =& $this->fp;
$this->response = '';
while($line = fgets($fp, 1024)) {
$this->response .= $line;
}
return $this->response;
}
?>
I think it may be geting into an infinite loop. With nntp protocol you can
test for a fullstop and then stop reading, does anyone know if there is
somthing like this in msn messenger protocol? has anyone else had this
problem.
I rewrote the class using the socket functions such as socket_create(),
socket_connect() and socket_read() but had the same problems. Is it a
problem with my code or is it somthing to do with the way the server is
working? help me!
Thanks, Mike
--
MGS2 Online
http://www.mgs2online.f2s.com