note 115903 added to function.socket-read

From: Date: Sun, 12 Oct 2014 21:39:30 +0000
Subject: note 115903 added to function.socket-read
Groups: php.notes 
Request: Send a blank email to php-notes+get-200631@lists.php.net to get a copy of this message
quote: "Note: socket_read() returns a zero length string ("") when there is no more data to read." This is not true! In a while loop (example case few bytes to receive - just enough for 1 call, but you use a loop to be sure you received all data) if you use <? socket_set_block($socket); ?> you will get: 1st call in loop: data 2nd call in loop: a block forever, if there isnt data anymore or w/e happen to the "other side" So ofc you want to use <? socket_set_nonblock($socket); ?> and you will get: 1st call in loop: data 2nd call in loop: socket_read() returns FALSE (bool) and socket_last_error() gives you a SOCKET_EWOULDBLOCK (http://de1.php.net/manual/de/sockets.constants.php) There is not a single time i got a empty string back from socket_read. And im "working" on this problem(bug?) since a week or so. You better use socket_recv() instead. (good luck) ---- Server IP: 212.124.37.9 Probable Submitter: 146.52.85.150 ---- Manual Page -- http://php.net/manual/en/function.socket-read.php Edit -- https://master.php.net/note/edit/115903 Del: integrated -- https://master.php.net/note/delete/115903/integrated Del: useless -- https://master.php.net/note/delete/115903/useless Del: bad code -- https://master.php.net/note/delete/115903/bad+code Del: spam -- https://master.php.net/note/delete/115903/spam Del: non-english -- https://master.php.net/note/delete/115903/non-english Del: in docs -- https://master.php.net/note/delete/115903/in+docs Del: other reasons-- https://master.php.net/note/delete/115903 Reject -- https://master.php.net/note/reject/115903 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200631) next »