Socket warning
| From: | Tan Ai Leen | Date: | Tue, 17 Feb 2004 08:29:43 +0000 |
| Subject: | Socket warning | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-177906@lists.php.net to get a copy of this message | ||
Hi all,
I programmed a server to bind to an external server(Let's call it C-server). My server will have to listen on the connection to C-server and send over data frequently. Each write of data to C-server from my server will cause C-server to response a string.
So the codes will be something like this:
if($response)
{ socket_write($read_socket, "$response", strlen($response));
echo $response."\n";
}
...
some processing to construct string to be send over
...
foreach($message as $part)
{
socket_write($this->c_socket, $part);
echo $part."\n";
$out = socket_read($this->c_socket, 1024);
echo $out."\n";
error_log($part.":".$out."\n", 3, $this->logfile);
}
Everytime the execution reaches socket_write($this->c_socket, $part);
a php warning is issued
<br />
<b>Warning</b>: socket_read() unable to read from socket [11]: Resource temporarily unavailable in <b>/var/www/html/dreamscape_mg/connectors/celcom/mo.php</b> on line <b>134</b><br />
Line 134 is the curl brace after the foreach. I am assuming that the socket read would be $out = socket_read($this->c_socket, $part). Why do I get the warning? c_socket is non blocking.
Thanks for your help
Ai Leen