|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44197 socket array keys lost on socket_select
Submitted: 2008-02-21 00:18 UTC Modified: 2012-03-23 17:27 UTC
Avg. Score:3.5 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: darrel dot opry at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Sockets related
PHP Version: 5.2.5 OS: Linux
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: darrel dot opry at gmail dot com
New email:
PHP Version: OS:


 [2008-02-21 00:18 UTC] darrel dot opry at gmail dot com
When you pass a keyed array of sockets into socket_select the keys are lost.

Reproduce code:
$clients = array();
$listener = socket_create_listen(9999);
$clients[uniqid()] = socket_accept($listener);

$read = $clients;
socket_select($read, $w = NULL, $e = NULL, NULL);

Expected result:
to test: 
telnet localhost 9999
enter text, hit enter.

I expect the second print_r($read) to have the same key as the first print_r($read).

Actual result:
     [47bcc1d71874d] => Resource id #5
     [0] => Resource id #5


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-21 02:35 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2008-07-15 13:01 UTC]
Note: This fix is in PHP 5.3.0 and upwards as it changes the behaviour.. 
 [2008-12-27 05:46 UTC]
What exactly is the change in behaviour?
 [2012-03-23 17:27 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 19:01:28 2024 UTC