Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TcpClient Sockets

Status
Not open for further replies.

millzy7

Programmer
Dec 9, 2003
96
US
Hi,

I am using TcpClient/TcpListener Sockets and C#. It works perfectly.

Except when i have a lot of clients trying to make a connection to the server at the same time.

Can i handle this with TcpClient/TcpListener, is there a way of telling it to queue up the attempts to connect rather than failing them as it does now?

Thanks

Millzy
 
Look into using asynchronous socket calls. These are based on the Windows IOCompletionPort objects, and are the same thing that IIS and other high-performance components use. You will, however, need to rearchitect your code to accomodate this.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks Chip,

I'm using Asynchronous Sockets now, e.g

callbackRead = new AsyncCallback(this.OnReadComplete);

sockStream.BeginRead(buf, 0, buf.Length, callbackRead, null);

But i get an error sometimes saying "an operation on a socket could not be performed because the system lacked sufficient buffer space or because
a queue was full"

Shouldnt Asynchronous Sockets have taken care of this?

I am still using this line of code

TcpListener tcpListener;
Socket sockToClient = tcpListener.AcceptSocket();

Are TCPListeners Asynchronous?

Thanks

Millzy
 
How many sockets do you have open?
Do you have a thread that closes dormant sockets (where there's been no activity for 5 minutes, etc)?

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top