Re: Breaks on socket_read
| From: | Marek Kilimajer | Date: | Sat, 15 May 2004 11:18:44 +0000 |
| Subject: | Re: Breaks on socket_read | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186291@lists.php.net to get a copy of this message | ||
René Fournier wrote:
Can anyone suggest why this script (well, part of the script) fails on the "while(($bug=socket_read..." line after it successfully loops several times? (Of course, it is only after it timesout, but that is what I need it to do.)
---CODE----------------------------------
$msg_recv = 3;
$timeout = array('sec' => 5, 'usec' => 0);
// ENTER LOOP
do {
$data = "";
socket_set_block($socket);
socket_set_option($socket,SOL_SOCKET,SO_RCVTIMEO,$timeout);
while(($buf = socket_read($socket,128,PHP_BINARY_READ)) !==
false) { <<<
$data .= $buf;
---OUTPUT----------------------------------
PHP Warning: socket_read() unable to read from socket [35]: Resource temporarily unavailable in /Users/rene/Sites/gpspolice/titan/cr.php on line 65
Because the read operation times out, so you get this warning. If you don't want this warning to show up use $buf = @socket_read($socket,128,PHP_BINARY_READ) and check with socket_last_error() what is going on.