On some systems I experimented you can "wake up" the port in TIME_WAIT state by trying to open a connection to it (i.e. by telnet localhost 80)
2010/10/23 Jonathan Lundell <jlund...@pobox.com>: > On Oct 23, 2010, at 7:54 AM, mdipierro wrote: >> >> I am teaching a class on Advanced network programming in C?? (nothing >> web2py related) and students are reporting to me that Mac OSX takes a >> long time to release a port after the program creating the socket has >> been killed or crashed. The delay seems to be as large as one minute. >> During this time the socket cannot be used again. >> >> It is a OSX weirdness. > > This list is useful for all kinds of problems... > >> This is quite common. Depending on how the socket it closed, the >> corresponding TCP connection can enter the TIME_WAIT state, which will keep >> the port busy for 2 minutes. >> >> <http://www.unixguide.net/network/socketfaq/2.7.shtml> >> >> A server would usually set SO_REUSEADDR to avoid this delay. >> >> <http://www.unixguide.net/network/socketfaq/4.5.shtml> >