Req #25769 [Fbk->NoF]: faster client lookup after socket_select
| From: | php-bugs at lists dot php dot net | Date: | Tue, 30 Dec 2014 10:41:24 +0000 |
| Subject: | Req #25769 [Fbk->NoF]: faster client lookup after socket_select | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189370@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: php-bugs@lists.php.net
Reported by: Xuefer at 21cn dot com
Summary: faster client lookup after socket_select
-Status: Feedback
+Status: No Feedback
Type: Feature/Change Request
Package: *General Issues
Operating System: Irrelevant
PHP Version: 4.3.4RC1
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2014-04-17 14:40:27] levim@php.net
I'm not sure I understand what you are wanting. Can you clarify?
------------------------------------------------------------------------
[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