views:

60

answers:

2

I currently have a select() statement configured to keep track of two UDP sockers. I send perhaps 10 - 20 messages a second at one general data socket, which is this interpreted as I expected.

However, once I hit around 1024 messages, I get the notice:

talker: socket: Too many open files talker: failed to bind socket

This is logical to me, since ulimit -n shows a max of 1024 open files for this user. However, why are there all of these open files? With UDP, there is no connection made, so I do not believe I need to be closing a socket each time (although perhaps I'm wrong).

Any ideas? Thanks in advance.

+1  A: 

I think in this case "Too many open files" really means you've hit the file descriptor limit; network sockets count towards this limit. Are you sure that there's nothing else - say in routehelper - that's creating further sockets?

What platform are you running on? If Linux, lsof or grobbling around in /proc/<pid>/fd - while it's running, before it hits the limit - might illustrate where all the fds are going.

Tip: Don't rely on socket_udp_inboundALL being numerically larger than socket_udp_inboundRC - it's better to explicitly compare their values at least once.

crazyscot
Thank you -- lsof pointed me into the right direction. Full explanation below.
BSchlinker
+1  A: 

If you are on Linux do an strace(1) on the client to check for the socket(2) and open(2) vs close(2) system calls (try -e trace=socket,open,close option). This is the easiest way to balance the file descriptor count at this point.

Nikolai N Fetissov
Thanks -- I was unaware of this option. lsof helped me this time, but perhaps strace will be help next time (+1).
BSchlinker
Yes, that's a great one to keep in your toolbox, along with `lsof` and `tcpdump` :)
Nikolai N Fetissov