From: samm at os2 dot kiev dot ua Operating system: Linux PHP version: master-Git-2012-10-16 (Git) Package: Sockets related Bug Type: Feature/Change Request Bug description:Add support to establish > 1 persistent connection to the same UNIX socket
Description: ------------ I found that it is possible to establish > 1 persistent connections with unique_id to TCP socket using syntax provided below: $s1=stream_socket_client('tcp://127.0.0.1:1234/id1', $errno, $errstr, 3, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); $s2=stream_socket_client('tcp://127.0.0.1:1234/id2', $errno, $errstr, 3, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); id1 and id2 are an unique identifiers which i can use later. This way i can use > 1 persistent connection to the same host->port. Unfortunately it does not work for the UNIX socket type. My proposed change is to add optional columnn (:) to the UNIX socket and use it as identifier. E.g. $s1=stream_socket_client('unix:////var/run/unix.sock:id1', $errno, $errstr, 3, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); $s2=stream_socket_client('unix:////var/run/unix.sock:id2', $errno, $errstr, 3, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); Part before column is used as socket path name, path after columnt - as connection id. Test script: --------------- <?php $sock = stream_socket_client('unix:////var/run/unix.sock:234', $errno, $errstr, 3, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); if($errno) echo $errstr."\n"; $sock2 = stream_socket_client('unix:////var/run/unix.sock:123', $errno, $errstr, 3, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); if($errno) echo $errstr."\n"; // here we can use "netstat -an|grep unix.sock" to control number of established connections sleep(1000)); ?> Expected result: ---------------- no connection errors and 2 different connections Actual result: -------------- connection error -- Edit bug report at https://bugs.php.net/bug.php?id=63293&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63293&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63293&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63293&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63293&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63293&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63293&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63293&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63293&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63293&r=support Expected behavior: https://bugs.php.net/fix.php?id=63293&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63293&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63293&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63293&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63293&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63293&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63293&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63293&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63293&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63293&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63293&r=mysqlcfg