note 64728 added to function.socket-select

From: Date: Thu, 20 Apr 2006 02:35:55 +0000
Subject: note 64728 added to function.socket-select
Groups: php.notes 
Request: Send a blank email to php-notes+get-108725@lists.php.net to get a copy of this message
Another solution to the problem of keys not being preserved is to have an additional array for looking up sockets that uses their resource identifiers as keys. This can be obtained using array_flip() in some cases, but is particularly useful if each socket is associated with an object. In this case, you can make the object's constructor add a pointer to itself to the lookup array with its socket resource identifier as a key and use the following code to execute a read method for the object associated with each socket returned by socket_select(): <?php socket_select($reads, $writes, $excepts, 0); foreach ($sockets as $socket) { $lookuparray[$socket]->read(); } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 24.126.82.151 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.socket-select.php Edit -- http://master.php.net/note/edit/64728 Del: integrated -- http://master.php.net/note/delete/64728/integrated Del: useless -- http://master.php.net/note/delete/64728/useless Del: bad code -- http://master.php.net/note/delete/64728/bad+code Del: spam -- http://master.php.net/note/delete/64728/spam Del: non-english -- http://master.php.net/note/delete/64728/non-english Del: in docs -- http://master.php.net/note/delete/64728/in+docs Del: other reasons-- http://master.php.net/note/delete/64728 Reject -- http://master.php.net/note/reject/64728 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#108725) next »