note 31711 added to function.socket-read

From: Date: Thu, 01 May 2003 02:04:28 +0000
Subject: note 31711 added to function.socket-read
Groups: php.notes 
Request: Send a blank email to php-notes+get-47315@lists.php.net to get a copy of this message
the read function causes windows to crash when someone disconnects while the script is trying to read. i came up with this small function that eliminates that problem: <? function read(&$sock,&$buff,$len){ $buff = socket_read($sock,$len,PHP_BINARY_READ); if(strlen($buff) == $len) return true; else return false; } ?> $sock = what ever your socket is; $buff = has to be an already defined variable since its passed by refference $len = the number of bytes to read the function returns true if it still has something to read, false if it has recieved everything -- http://www.php.net/manual/en/function.socket-read.php http://master.php.net/manage/user-notes.php?action=edit+31711 http://master.php.net/manage/user-notes.php?action=delete+31711 http://master.php.net/manage/user-notes.php?action=reject+31711

« previous php.notes (#47315) next »