Req #38739 [Com]: stream_socket_server should not require a port

From: Date: Mon, 15 Sep 2014 12:52:49 +0000
Subject: Req #38739 [Com]: stream_socket_server should not require a port
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187540@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=38739&edit=1 ID: 38739 Comment by: cf0hay at gmail dot com Reported by: magicaltux at ookoo dot org Summary: stream_socket_server should not require a port Status: Open Type: Feature/Change Request Package: Feature/Change Request Operating System: * PHP Version: 5.1.6 Block user comment: N Private report: N New Comment: Use tcp://0.0.0.0:0 . Port 0 has a special meaning, which will result in exactly what you want. Previous Comments: ------------------------------------------------------------------------ [2006-09-07 09:33:05] magicaltux at ookoo dot org Description: ------------ When trying, for example, to do : <?php $socket = stream_socket_server('tcp://0.0.0.0', $errno, $errstr); var_dump($errstr); ?> We get the following output : Warning: stream_socket_server(): unable to connect to tcp://0.0.0.0 (Failed to parse address "0.0.0.0") in /home/magicaltux/- on line 2 string(33) "Failed to parse address "0.0.0.0"" Expected result would be to have no port passed to bind, and thru having a random port allocated by the operating system (that we would later retrieve with stream_socket_get_name). In socket_bind, the port is also optionnal. It's still possible to get a random port by using ":0" but the no-port behaviour would be great too (and probably not too hard to implement). Reproduce code: --------------- <?php $socket = stream_socket_server('tcp://0.0.0.0', $errno, $errstr); var_dump($errstr); ?> Expected result: ---------------- string(0) "" Actual result: -------------- Warning: stream_socket_server(): unable to connect to tcp://0.0.0.0 (Failed to parse address "0.0.0.0") in /home/magicaltux/- on line 2 string(33) "Failed to parse address "0.0.0.0"" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=38739&edit=1

« previous php.bugs (#187540) next »