Fundamental Socket Question

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
 
C

C# Learner

On Wed, 22 Sep 2004 21:00:57 +0100, C# Learner wrote:

<snip>

Nevermind; I was looking in the wrong place.
 
D

Drebin

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top