Home:ALL Converter>socket_listen() ignores 'backlog' parameter, how to set connections limit then?

socket_listen() ignores 'backlog' parameter, how to set connections limit then?

Ask Time:2013-12-13T05:02:06         Author:Damaged Organic

Json Formatter

From the manual:

The maximum number passed to the backlog parameter highly depends on the underlying platform. On Linux, it is silently truncated to SOMAXCONN. On win32, if passed SOMAXCONN, the underlying service provider responsible for the socket will set the backlog to a maximum reasonable value. There is no standard provision to find out the actual backlog value on this platform.

Hell, what if I still want to limit connections myself? Limiting connections like:

if( count($client_sockets) < $max_clients ) {
    //accept connection
} else {
    echo "Limit reached!";
}

will not work well in combination with socket_select(), because function still got incoming connection, that server needs to handle properly! Accepting connection > $max_clients and than closing it right away is not an option, so... Maybe anyone knows how to do it?

Author:Damaged Organic,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/20554172/socket-listen-ignores-backlog-parameter-how-to-set-connections-limit-then
yy