Req #38739 [Opn->Wfx]: stream_socket_server should not require a port

From: Date: Sat, 05 May 2018 18:36:06 +0000
Subject: Req #38739 [Opn->Wfx]: stream_socket_server should not require a port
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215076@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 Updated by: requinix@php.net Reported by: magicaltux at ookoo dot org Summary: stream_socket_server should not require a port -Status: Open +Status: Wont fix Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: * PHP Version: 5.1.6 Block user comment: N Private report: N New Comment: Old request is old. Specifying port 0 is very much a standard practice. Previous Comments: ------------------------------------------------------------------------ [2014-09-15 12:52:49] cf0hay at gmail dot com Use tcp://0.0.0.0:0 . Port 0 has a special meaning, which will result in exactly what you want. ------------------------------------------------------------------------ [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 (#215076) next »