by peter » 07 Feb 2007, 13:06
> Hey guys, doing some testing with TCPServer and running into an issue. I have a lot of connections coming in, which I read some bytes from and close. After awhile I start getting too many files open. It is possible the connection might not complete (meaning TCP handshake). Is there anything I am missing. I want to make sure the socket is closed if:
>
> a) The TCP handshake does not complete as soon as possible.
> b) Once I read the bytes.
>
> Now I assume the socket is closed after run() exits so I am a little lost why I am getting "Too many files open". Any help is appreciated.
Hi Electic,
normally you shouldn't need to call _socket.close() explicitly in your application.
The socket gets closed once the TCPConnection gets thrown away.
You can try to call socket().close() in your TcpConnectionHandler manually
but I suspect it won't do you much good.
On which platform are your working? Windows has (in the default installation)
problems with the number of open ports. There is an upper limit on the amount of sockets
an application can open (even setting SO-REUSE doesn't help here, since it takes Windows approx 2 minutes until a socket can be reused). This behavior an be tweaked via
a registry setting but I don't remember what I had to change...
There is also a limit on (unsuccessful) TCP connection attempts. See http://www.speedguide.net/read_articles.php?id=1497 for more info.
This is kinda hard to fix, though.
Another possible solution is TCPServer configuration. Which TCPServerParams
do you pass to your TCPServer? What is the number of maximum worker threads,
what is the maxQueue size. Per default numThreads is unlimited (set to 0) and
maxQueue is 64.
br
Peter