Req #25769 [Opn->Fbk]: faster client lookup after socket_select

From: Date: Thu, 17 Apr 2014 14:40:29 +0000
Subject: Req #25769 [Opn->Fbk]: faster client lookup after socket_select
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185330@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=25769&edit=1 ID: 25769 Updated by: levim@php.net Reported by: Xuefer at 21cn dot com Summary: faster client lookup after socket_select -Status: Open +Status: Feedback Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues -Operating System: - +Operating System: Irrelevant PHP Version: 4.3.4RC1 Block user comment: N Private report: N New Comment: I'm not sure I understand what you are wanting. Can you clarify? Previous Comments: ------------------------------------------------------------------------ [2003-10-06 23:26:47] Xuefer at 21cn dot com Description: ------------ it's slow that phpscript itself have to loop through $fds and use in_array to know which client is sending data $allfds[0] = socket_create(...); $clients[0] = new MyClient($allfds[0]); ... $count = socket_select($fds); for ($i = 0; $i < FDSIZE; $i ++) { if (in_array($fds, $allfds[$i])) { $clients[$i]->processIncomingData(); } } larger FDSIZE make script slower i'd suggest $fd resource store more information: ID int socket_set_id(source $sock) int socket_get_id(source $sock) $allfds[0] = socket_create(...); $clients[0] = new MyClient($allfds[0]); socket_set_id($allfds[0], 0); $allfds[1] = socket_create(...); $clients[1] = new MyClient($allfds[1]); socket_set_id($allfds[1], 1); $count = socket_select($fds); for ($i = 0; $i < $count; $i ++) { $id = socket_get_id($fds[$i]); $clients[$id]->processIncomingData(); } speed is not depend on FDSIZE ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=25769&edit=1

« previous php.bugs (#185330) next »