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 开发者_Python百科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.
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.
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.
精彩评论