How to free a port that has been used by a python server?
rushing at sPaM.nightmare.com
rushing at sPaM.nightmare.com
Mon Jun 5 01:43:47 EDT 2000
In article <etdg0qvtkel.fsf at w20-575-109.mit.edu>, Alex
<cut_me_out at hotmail.com> wrote:
>
> Is there some way to free up port 1729 when proxy gets destroyed?
>
> I'm running RedHat Linux, but I have also seen this problem with
> Solaris.
If you wait a couple of minutes, the port will be freed.
If you don't like waiting, try something like this (from asyncore.py):
def set_reuse_addr (self):
# try to re-use a server port if possible
try:
self.socket.setsockopt (
socket.SOL_SOCKET, socket.SO_REUSEADDR,
self.socket.getsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1
)
except:
pass
-Sam
More information about the Python-list
mailing list