Req #49416 [Opn->Csd]: Add stream_socket_listen() and stream_socket_set_option() functions
Edit report at https://bugs.php.net/bug.php?id=49416&edit=1
ID: 49416
Updated by: bukka@php.net
Reported by: kak dot serpom dot po dot yaitsam at gmail dot com
Summary: Add stream_socket_listen() and
stream_socket_set_option() functions
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Streams related
Operating System: *
PHP Version: *
-Assigned To:
+Assigned To: bukka
Block user comment: N
Private report: N
New Comment:
This has all been addressed and there are socket stream context options for backlog, so_reuseport
and so_reuseaddr (enabled by default on the current version and just added this option to allow
disabling it).
Previous Comments:
------------------------------------------------------------------------
[2024-07-31 23:43:00] thewitness@php.net
Here is the reason for the backlog option. In this example, the default backlog of my system is
128:
sysctl -a | grep somaxconn
net.core.somaxconn = 128
I setup a stream_socket_server on port 2057 and I have this:
ss -lnp | grep "2057"
tcp LISTEN 0 32 *:2057 *:*
users:(("php",pid=11297,fd=7))
You see, I have no way to set it. It's that simple.
------------------------------------------------------------------------
[2024-07-31 23:17:10] thewitness@php.net
The stream_socket_server() function is implemented incorrectly on the backend. For example,
I'm unable to create a connection with an acl.
I can create this:
tcp://0.0.0.0:someport
but not:
tcp://192.168.11.0:someport
This would normally allow any host on the 192.168.11.0 network to speak to the connection. Instead
you get an error that it can not validate the hostname. There is really no reason to validate it,
it's a network and not a host.
Also, the default backlog, as seen in some comments is only 5, and not configurable similar to the
built in socket() functions.
------------------------------------------------------------------------
[2014-07-15 16:32:37] jpauli@php.net
I can't get how libevent would change anything on your problem. Could you elaborate please,
knowing PHP wont use such a layer internally anyway ?
Also, I would strongly recommand you to use ext/socket.
ext/socket is a very thin wrapper over OS's socket capabilities, whereas stream_ suffer from a
much more complex layer.
For example, for socket low level option, such as SO_REUSE , ext/socket is much more suitable. http://www.php.net/ref.sockets
------------------------------------------------------------------------
[2009-08-30 14:27:56] kak dot serpom dot po dot yaitsam at gmail dot com
Description:
------------
Please, add function stream_socket_listen(resource,backlog):
it should call listen() for the socket created by
stream_socket_server beforehand.
I need to use stream_socket_server but I can not use socket_*,
because of libevent.
Also, it would be nice to have a stream_socket_set_option function,
which allows to apply SO_REUSE and other parameters.
Thanks.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=49416&edit=1
Thread (3 messages)