php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38739 stream_socket_server should not require a port
Submitted: 2006-09-07 09:33 UTC Modified: 2018-05-05 18:36 UTC
Votes:3
Avg. Score:3.7 ± 1.2
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: magicaltux at ookoo dot org Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.1.6 OS: *
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: magicaltux at ookoo dot org
New email:
PHP Version: OS:

 

 [2006-09-07 09:33 UTC] 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""


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-15 12:52 UTC] 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.
 [2018-05-05 18:36 UTC] requinix@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2018-05-05 18:36 UTC] requinix@php.net
Old request is old.

Specifying port 0 is very much a standard practice.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 17:01:30 2024 UTC