note 117902 added to function.socket-read

From: Date: Fri, 28 Aug 2015 15:16:44 +0000
Subject: note 117902 added to function.socket-read
Groups: php.notes 
Request: Send a blank email to php-notes+get-203502@lists.php.net to get a copy of this message
A way to wait for a message response by the socket or take the first message incoming. Note that if the server turn offline, you have a socket resource, but while trying socket_read(), it gives you a warning message that will fill your hard drive kickly due to logging. The example above try read the message at best 3 times, 3 seconds sleeping for another reading. <?php function waitResponse($response = "") { $status = ""; $tries = 3; $counter = 0; while ($status == $response) { $status = socket_read($socket, 1024); if(!$status){ if($counter >= $tries){ break; }else{ $counter++; sleep(3); } } } return $response; } ---- Server IP: 72.52.91.14 Probable Submitter: 201.22.227.119 ---- Manual Page -- http://php.net/manual/en/function.socket-read.php Edit -- https://master.php.net/note/edit/117902 Del: integrated -- https://master.php.net/note/delete/117902/integrated Del: useless -- https://master.php.net/note/delete/117902/useless Del: bad code -- https://master.php.net/note/delete/117902/bad+code Del: spam -- https://master.php.net/note/delete/117902/spam Del: non-english -- https://master.php.net/note/delete/117902/non-english Del: in docs -- https://master.php.net/note/delete/117902/in+docs Del: other reasons-- https://master.php.net/note/delete/117902 Reject -- https://master.php.net/note/reject/117902 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203502) next »