From: Xuefer at 21cn dot com
Operating system: -
PHP version: 4.3.4RC1
PHP Bug Type: Feature/Change Request
Bug description: faster client lookup after socket_select

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 bug report at [url]http://bugs.php.net/?id=25769&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=25769&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=25769&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=25769&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=25769&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=25769&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=25769&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=25769&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=25769&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=25769&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=25769&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=25769&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=25769&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=25769&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=25769&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=25769&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=25769&r=float[/url]