Click to See Complete Forum and Search --> : Connection refused
cabasm
September 22nd, 2003, 04:24 AM
I wrote my own TCP server and a TCP client that creates 30 connections to the server (30 threads). Only the first 20-21 connections are established successfully, the other 4-5 are rejected by the server. The error code is 10061 (connection actively refused by the remote host). After running the client again, the same happens. How can I solve the problem? What is going on on the server and client side? I think the TCP stack cannot handle with more than xxx conncetions on the same time.
I'm using w2k.
Mick
September 22nd, 2003, 07:07 AM
Originally posted by cabasm
I wrote my own TCP server and a TCP client that creates 30 connections to the server (30 threads). Only the first 20-21 connections are established successfully, the other 4-5 are rejected by the server. The error code is 10061 (connection actively refused by the remote host). After running the client again, the same happens. How can I solve the problem? What is going on on the server and client side? I think the TCP stack cannot handle with more than xxx conncetions on the same time.
I'm using w2k.
what is your listen backlog set to? You might have to post some code, I've run benchmark tests in the past, which have filled the connections up far more than 30, the max user port connections is by default 5000, and does return connection refuesd (under NT not sure if they fixed that on w2k) when it really should return "no ports available" when it exceeds the maximum number of ports avail.
any who...
The listen function is typically used by servers that can have more than one connection request at a time. If a connection request arrives and the queue is full, the client will receive an error with an indication of WSAECONNREFUSED.
cabasm
September 22nd, 2003, 08:54 AM
the backlog is set to SOMAXCONN, i.e. 5, but if I increase the value of backlog it doesn't solve the problem.
Mick
September 22nd, 2003, 09:04 AM
Originally posted by cabasm
the backlog is set to SOMAXCONN, i.e. 5, but if I increase the value of backlog it doesn't solve the problem.
well I'd have to see your code, if you can reduce it to a simple listen project and a simple connect project executable that exhibits the problem that would work well. You can easily test that more than 30+ connections which can be generated by simply connecting via telnet to your echo port, which is port 7, and allowing those to run concurrently.
And to just point out it's something in your code, or configuration, the IP stack can handle well over 30 connections, and the OS can handle well over 30 threads to read from those connections.
dimm_coder
September 23rd, 2003, 04:03 AM
How do U open connections? 30 at the one moment (I mean in the loop)? If so,
The problem could be because listen() has some queue for input requests (as it was mentioned above) and when U try to open 30 connections at the one moment (it is very quickly when both client and server are on the same computer) this queue cannot accept all of them. For test U can set some small timeout interval in the openning connections loop.
But, it is difficult here to give advice without code samples.
cabasm
September 23rd, 2003, 07:23 AM
I solved the problem. The W2k workstation has its limits: it cannot handle 20-30 simultan connections. This is not happening on w2k server editions.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.