Fundamental Socket Question

  • Thread starter Thread starter C# Learner
  • Start date Start date
C

C# Learner

When I try to set/get a System.Net.Sockets.Socket's MaxConnections socket
option value, an exception is thrown.

Is the MaxConnections field not supported on Windows?

Example code:

Socket socket = new Socket(AddressFamily.Unspecified,
SocketType.Stream, ProtocolType.Tcp);
socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.MaxConnections, 5);

Exception message:

An unhandled exception of type 'System.Net.Sockets.SocketException'
occurred in system.dll

Additional information: An unknown, invalid, or unsupported option or
level was specified in a getsockopt or setsockopt call
 
On Wed, 22 Sep 2004 21:00:57 +0100, C# Learner wrote:

<snip>

Nevermind; I was looking in the wrong place.
 
For furture reference:

try
{
Socket socket = new Socket(AddressFamily.Unspecified,
SocketType.Stream, ProtocolType.Tcp);
socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.MaxConnections, 5);
}
catch (System.Net.Sockets.SocketException se)
{
string strErr = se.Message
}


strErr will have the details of the exception.
 
Back
Top