473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Max TCP client connections???

I'm creating a tcp socket connection from the thread in the c#
threadpool. Since the default workers thread is 500, sometimes my
program tries to open up 500 different tcp socket connections and the
connection fails after it reaches certain number of opened tcp
connection. I guess it reached the max number of tcp connection
available in the operating system. I have Professional Windows XP
2000. So what is the max simultaneous tcp connection in this
operating system? Or how can I find out the how many tcp connections
are available?

Thanks

Jan 16 '08 #1
9 24486
On Wed, 16 Jan 2008 11:16:25 -0800, Greg <gc*****@gmail.comwrote:
I'm creating a tcp socket connection from the thread in the c#
threadpool. Since the default workers thread is 500, sometimes my
program tries to open up 500 different tcp socket connections and the
connection fails after it reaches certain number of opened tcp
connection. I guess it reached the max number of tcp connection
available in the operating system. I have Professional Windows XP
2000. So what is the max simultaneous tcp connection in this
operating system? Or how can I find out the how many tcp connections
are available?
I may be wrong, but I wasn't aware of any arbitrary maximum number of
connections possible, even on a non-server version of Windows.

Your message _seems_ to be saying that you are using a thread pool thread
to create each connection. If by that you mean that each connection has
its own thread pool thread, then it seems likely to me that you're
actually running out of threads, not connections.

If you want to host a large number of multiple connections, you need to
avoid a "one thread per connection" implementation. That technique will
always unnecessarily limit the number of connections you can have at once,
and performance will suffer even before you reach that limit.

Instead, look at the asynchronous API on the Socket class (or TcpClient
and Stream if that's what you're using), where you call methods with
"Begin" and "End" as part of the names. For example,
Socket.BeginConnect() and Socket.BeginRead(). These methods provide a
much more scalable and efficient way of managing multiple connections with
the same parallelism that multiple threads would give you, but without the
limitations. (In fact they do use threads themselves, but in a much more
efficient way than dedicating one to each connection).

If I've misunderstood your architecture, then you should probably post a
concise-but-complete example of code that illustrates what you _are_
doing. It's too easy to misunderstand a human language description of an
implementation, but code is code. :)

Pete
Jan 16 '08 #2
Hi,
You can either be running out of TCP connections (which I do not think ) or
of threads (which I think is the cause of your problem). Try to increase the
number of threads.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Greg" <gc*****@gmail.comwrote in message
news:3b**********************************@l32g2000 hse.googlegroups.com...
I'm creating a tcp socket connection from the thread in the c#
threadpool. Since the default workers thread is 500, sometimes my
program tries to open up 500 different tcp socket connections and the
connection fails after it reaches certain number of opened tcp
connection. I guess it reached the max number of tcp connection
available in the operating system. I have Professional Windows XP
2000. So what is the max simultaneous tcp connection in this
operating system? Or how can I find out the how many tcp connections
are available?

Thanks

Jan 16 '08 #3
Ignacio Machin ( .NET/ C# MVP ) wrote:
You can either be running out of TCP connections (which I do not think ) or
of threads (which I think is the cause of your problem). Try to increase the
number of threads.
No, please don't follow this advice. If you're hitting the thread pool
default maximum of 500 worker threads, you're doing something wrong. That's
just not a reasonable amount of threads to use. "500" is as good as
"infinity" here, unless you have a machine with, say, 100 processors, and
memory to burn.

--
J.
Jan 16 '08 #4
Hi,
"Jeroen Mostert" <jm******@xs4all.nlwrote in message
news:47***********************@news.xs4all.nl...
Ignacio Machin ( .NET/ C# MVP ) wrote:
>You can either be running out of TCP connections (which I do not think )
or of threads (which I think is the cause of your problem). Try to
increase the number of threads.
No, please don't follow this advice. If you're hitting the thread pool
default maximum of 500 worker threads, you're doing something wrong.
That's just not a reasonable amount of threads to use. "500" is as good as
"infinity" here, unless you have a machine with, say, 100 processors, and
memory to burn.
You have a point. It would be much better if the comm. are async and a
thread can handle more than one connection.
OP:
Do a search of how to do a high performance TCP server. I'm pretty sure you
will find something about how to handle 1K connections without killnig the
machine.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Jan 16 '08 #5
On Wed, 16 Jan 2008 13:41:28 -0800, Ignacio Machin ( .NET/ C# MVP )
<machin TA <"laceupsolutions.com>"wrote:
[...]
You have a point. It would be much better if the comm. are async and a
thread can handle more than one connection.
OP:
Do a search of how to do a high performance TCP server. I'm pretty sure
you
will find something about how to handle 1K connections without killnig
the
machine.
Or, he could just read the article I posted in reply to his original
message:
<http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/9d98656262435eb5/c6228fc1e8ade078#c6228fc1e8ade078>

I'm curious: that article has not shown up on my news server yet. I
suspect it never will. Obviously it was sent, since Google has it. Are
others not receiving it either? I could repost it, but since the main
point for doing so would be to ensure it's in the archive, and since it's
obviously already in the archive, I think there's probably no point in me
doing that.

The even shorter version of my relatively short reply is: use the
asynchronous methods on the Socket or TcpClient and Stream classes, as
appropriate. Those methods have names that all start with either "Begin"
or "End". Using that mechanism, handling a thousand connections would be
trivial; hundreds of thousands of connections should be possible, assuming
no other limitations.

Pete
Jan 16 '08 #6
On Jan 16, 11:16 am, Greg <gcad...@gmail.comwrote:
I'm creating a tcp socket connection from the thread in the c#
threadpool. Since the default workers thread is 500, sometimes my
program tries to open up 500 different tcp socket connections and the
connection fails after it reaches certain number of opened tcp
connection. I guess it reached the max number of tcp connection
available in the operating system. I have Professional Windows XP
2000. So what is the max simultaneous tcp connection in this
operating system? Or how can I find out the how many tcp connections
are available?

Thanks
I'd like to thank everyone for a quick response and for sharing their
insight.
I just stumbled across this: http://forum.emule-project.net/lofiv...hp/t56016.html

It describes that XP SP1 has an unlimited of TCP client connection
requests whereas SP2 only allows 10 per second.
I've implemented a counter that increments on the request, and
decrements when connected. If the counter should reach 10, that thread
sleeps for a maximum of 1000ms waiting for a valid connection or
timeout. Whichever comes first.
It seems to work fine now, but will be running more test to confirm
these findings. Stay tuned.

Thanks again.

Greg

Jan 16 '08 #7
The magic setting you're looking for is "MaxUserPort". You can google this,
then make the appropiate registry change.

Thie value is typically set at 5000, and if you want lots and lots of client
connections then you need to bump the value up.

--
Chris Mullins

"Greg" <gc*****@gmail.comwrote in message
news:3b**********************************@l32g2000 hse.googlegroups.com...
I'm creating a tcp socket connection from the thread in the c#
threadpool. Since the default workers thread is 500, sometimes my
program tries to open up 500 different tcp socket connections and the
connection fails after it reaches certain number of opened tcp
connection. I guess it reached the max number of tcp connection
available in the operating system. I have Professional Windows XP
2000. So what is the max simultaneous tcp connection in this
operating system? Or how can I find out the how many tcp connections
are available?

Thanks

Jan 17 '08 #8
Hi Peter,

I never got it, and I have the configuration to get like 1000 messages.

I have notices the same thing with some of my posts though.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 16 Jan 2008 13:41:28 -0800, Ignacio Machin ( .NET/ C# MVP )
<machin TA <"laceupsolutions.com>"wrote:
>[...]
You have a point. It would be much better if the comm. are async and a
thread can handle more than one connection.
OP:
Do a search of how to do a high performance TCP server. I'm pretty sure
you
will find something about how to handle 1K connections without killnig
the
machine.

Or, he could just read the article I posted in reply to his original
message:
<http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/9d98656262435eb5/c6228fc1e8ade078#c6228fc1e8ade078>

I'm curious: that article has not shown up on my news server yet. I
suspect it never will. Obviously it was sent, since Google has it. Are
others not receiving it either? I could repost it, but since the main
point for doing so would be to ensure it's in the archive, and since it's
obviously already in the archive, I think there's probably no point in me
doing that.

The even shorter version of my relatively short reply is: use the
asynchronous methods on the Socket or TcpClient and Stream classes, as
appropriate. Those methods have names that all start with either "Begin"
or "End". Using that mechanism, handling a thousand connections would be
trivial; hundreds of thousands of connections should be possible, assuming
no other limitations.

Pete

Jan 17 '08 #9
Hi Pete,

Your article showed up fine for me.

It is on the ms newsgroup server as expected.

John

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
Or, he could just read the article I posted in reply to his original
message:
<http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/9d98656262435eb5/c6228fc1e8ade078#c6228fc1e8ade078>

I'm curious: that article has not shown up on my news server yet. I
suspect it never will. Obviously it was sent, since Google has it. Are
others not receiving it either? I could repost it, but since the main
point for doing so would be to ensure it's in the archive, and since it's
obviously already in the archive, I think there's probably no point in me
doing that.

The even shorter version of my relatively short reply is: use the
asynchronous methods on the Socket or TcpClient and Stream classes, as
appropriate. Those methods have names that all start with either "Begin"
or "End". Using that mechanism, handling a thousand connections would be
trivial; hundreds of thousands of connections should be possible, assuming
no other limitations.

Pete

Jan 17 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin Fuzzey | last post by:
I am using xmlrpclib (based on httplib) in Python 2.3 on Mandrake Linux. When my client attempts to connect to a server using a "http://localhost:port" style URL there is a long delay before the...
0
by: MisterT | last post by:
Hello, I have a TCPclient and TCPListener created from MS sample code. They do communicate, but the client sockets do not seem to be closed totally even though there is a TCPclient.Close done...
3
by: Jo Davis | last post by:
www.shanje.com does sql server hosting, on shared servers, at a reasonable price. It seems. They also allow client connections. Just playing around I've managed to connect an Access Data Project...
0
by: al | last post by:
Any idea where can I get a copy of the libmysql dll with ssl enabled? Al
0
by: Jerome Macaranas | last post by:
Is there a way in postgres to view current client connections? including statistics.. how long did it take for him to connect and disconnect.. etc TIA ---------------------------(end of...
1
by: Mark Harrison | last post by:
We have the situation where it would be convenient if we could support a large number (>1024, possibly in the 2000-3000 range) of client connections. What are our options for this? Many TIA,...
3
by: D. Yates | last post by:
Hi, I'm about to embark on a project that will both send and receive information to/from our client computers in the field. The area that I still need to finalize is the method of...
0
by: shyamsunderrai | last post by:
Dear All, I am having the latest version of PostgreSQL i.e. 8.4.2 and in order to increase the number of client connection I have increased the parameters "max_connections" and "shared_buffers"...
11
by: Jeff | last post by:
Hello everyone. I've searched through the archives here, and it seems that questions similar to this one have come up in the past, but I was hoping that I could pick your Pythonic brains a bit. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.