> It's the way the host was programmed.

What he said ^

The only thing I'd add is that most tcp socket implementations have the
notion of a 'backlog' parameter of some sort that the host/listening app
sets when the first setup the socket that they'll accept incoming
connections on.  A pretty common default for that backlog # is 5.  It's been
awhile, but in C++, this was a parameter to one-of(bind, listen, accept).

The backlog is the # of new/pending connection requests that the underlying
socket layer will allow in while it's waiting for the host to get around to
calling accept again.  So N clients will sort of 'stall' in their call to
connect while the host is off handling something (assuming here it's not
doing any async processing like dg mentioned).  But client N+1 that attempts
to connect will get an immediate failure from their call to connect.

For example, if backlog=5, then the host could accept 1 connection and
proceed to deal with it.  Between then and when the host gets back to
calling accept the subsequent time, up to 5 more clients could connect
(although their call to connect will block).  The 6th client who attempts to
connect will fail their call to connect right away.  So the backlog
effectively tells the sockets layer the point at which you figure if you
haven't gotten around to dealing with those clients yet, you're not likely
to anytime soon.

But like David said, most socket-based apps use async i/o facilities (if
they exist on their platform) of one sort or another.  I know your host is
written in C++ right now, but fwiw, if you want some C# samples, you can
take a look at this sample:

http://www.bearcanyon.com/dotnet/#ConnectionLimit

It's just simple winforms app in C# that does nothing but allow an arbitrary
# of connections.  But it only uses one thread, so uses async i/o to achieve
the simultaneous connections.

-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
http://www.pluralsight.com/mike

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to