note 19301 added to function.socket-read

From: Date: Fri, 22 Feb 2002 14:23:44 +0000
Subject: note 19301 added to function.socket-read
Groups: php.notes 
Request: Send a blank email to php-notes+get-26933@lists.php.net to get a copy of this message
.. whereas this would be better: while(($buf = socket_read($socket, 512)) !== false) { // .. } this loop breaks if an error occurs (with type-checking of the return value). Because you don't know how much data you will receive, you should implement a condition which breaks the loop: while(($buf = socket_read($socket, 512)) !== false) { $data .= $buf; if(preg_match("'\r\n\r\n$'s", $data)) break; } .. which would break as soon as a <carriage return><new line><carriage return><new line> was sent. -- http://www.php.net/manual/en/function.socket-read.php http://master.php.net/manage/user-notes.php?action=edit+19301 http://master.php.net/manage/user-notes.php?action=delete+19301 http://master.php.net/manage/user-notes.php?action=reject+19301

« previous php.notes (#26933) next »