php.net |  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-10-06 23:26 UTC] 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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [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
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: Fri Apr 26 21:01:29 2024 UTC