Sybren Stuvel wrote: > Tor Erik enlightened us with: >> The reason is that my application does about 16 connects and data >> transfers per second, to the same 16 remote hosts. After approx 200 >> secs there are 4000 sockets waiting to be garbage collected by the >> OS. > > Which OS are we talking about?
Windows XP > >> At this point is seems that connect loops and starts using the same >> local addresses it used 4000 connections ago, resulting in an >> "Address already in use" exception. > > After how many seconds does this happen? 200 seconds approx > >> My question is if there are any other methods of solving this? Maybe >> a socket option of some sort... > > If I'm correct (please correct me if I'm not), on Linux you can use > 'sysctl -w net.ipv4.tcp_fin_timeout=X' to set the time between closing > the socket and releasing it to be reused. You can also check the > SO_REUSEADDR argument to the setsockopt function. Read 'man 7 socket' > for more info. I've read about SO_REUSEADDR. As far as I understand, this is what SO_REUSEADDR is for: 1. Allow a listening socket to bind itself to its well-known port even if previously established connections use it as their local port. Setting this option should be done between calls to socket and bind, and hence is only usable for listening sockets, not client sockets like mine. 2. Allow multiple servers on the same host with different ip-adresses to listen to the same port. I've tried setting this option, but could not see any notable changes... > > Sybren -- http://mail.python.org/mailman/listinfo/python-list