The System.Net.Sockets.Socket.Listen()
function requires a backlog
argument, which is the max number of connections that Listen()
can queue up.
From the MSDN documentation:
To determine the maximum number of connections you can specify, retrieve the
MaxConnections
value.
So I click on MaxConnections
and the link takes me to the page for SocketOptionName Enumeration
, which says:
MaxConnections: Not supported; will throw a SocketException if used.
So the documentation for this MaxConnections
enumeration says not to use it, but doesn't give an alternative. How do I determine the max connections, so that I have a value to pass into the Socket.Listen()
function?
The listen() call indicates a readiness to accept client connection requests. It transforms an active socket into a passive socket. Once called, socket can never be used as an active socket to initiate connection requests. Calling listen() is the third of four steps that a server performs to accept a connection.
The listen() function marks a connection-mode socket (for example, those of type SOCK_STREAM), specified by the socket argument s, as accepting connections, and limits the number of outstanding connections in the socket's listen queue to the value specified by the backlog argument.
Exception will be thrown when you will try to set socket option and use MaxConnections
as an option name, e.g.
listenSocket.SetSocketOption(..., SocketOptionName.MaxConnections, ...);
In contrast, as a backlog
argument it is meant to be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With