|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #25769 faster client lookup after socket_select
Submitted: 2003-10-06 23:26 UTC Modified: 2014-12-30 10:41 UTC
From: Xuefer at 21cn dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 4.3.4RC1 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: Xuefer at 21cn dot com
New email:
PHP Version: OS:


 [2003-10-06 23:26 UTC] Xuefer at 21cn dot com
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])) {
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]);
speed is not depend on FDSIZE


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-17 14:40 UTC]
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: *General Issues -Operating System: - +Operating System: Irrelevant
 [2014-04-17 14:40 UTC]
I'm not sure I understand what you are wanting. Can you clarify?
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 13:01:27 2024 UTC