socket maxconnections?

  • Thread starter Thread starter Ole
  • Start date Start date
O

Ole

As a newbie to socket communication I would like to know more about
'SocketOptionName.MaxConnections'. Everywhere I look for examples on using
socket I see the statement:
listenSocket.Listen((int)SocketOptionName.MaxConnections);
used , but the .NET documentation says this about Maxconnections: "Not
supported; will throw a SocketException if used."
What should I do and what is the code line actually doig?

Thanks
Ole
 
Hello, Ole!

O> As a newbie to socket communication I would like to know more about
O> 'SocketOptionName.MaxConnections'. Everywhere I look for examples on
O> using socket I see the statement:

O> listenSocket.Listen((int)SocketOptionName.MaxConnections);

Line above means that listenSocket state will be changed to LISTENING ( it will accept connections via Accept method ). And number of pending connections is equal to SocketOptionName.MaxConnections.

SocketOptionName.MaxConnections has the same value as int.MaxValue has ( 0x7fffffff ).

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, .... );

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Thanks. Still not sure what the number is actually good for: what would
happen if I wrote 1 instread of MaxConnections?

Best regards,
Ole
 
Hello, Ole!

That will mean that number pending connections will be equal to 1.
That is if there are a lot hosts that want to connect connection queue's size will be 1, thus
some hosts will be refused connection.
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 

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

Back
Top