|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-04-17 14:40 UTC] levim@php.net
-Status: Open
+Status: Feedback
-Package: Feature/Change Request
+Package: *General Issues
-Operating System: -
+Operating System: Irrelevant
[2014-04-17 14:40 UTC] levim@php.net
[2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 22:00:01 2025 UTC |
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