paperduck
paperduck

Reputation: 1195

How to determine MaxConnections for Socket.Listen()?

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?

Upvotes: 10

Views: 1343

Answers (1)

Roland Pihlakas
Roland Pihlakas

Reputation: 4573

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.

Upvotes: 3

Related Questions