socket.SO_REUSEADDR

This commit is contained in:
clowwindy
2014-06-01 14:53:06 +08:00
parent 5e9a9c9beb
commit 3cefe374c2
4 changed files with 14 additions and 10 deletions

View File

@ -294,6 +294,7 @@ class TCPRelay(object):
(listen_addr, listen_port))
af, socktype, proto, canonname, sa = addrs[0]
server_socket = socket.socket(af, socktype, proto)
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind(sa)
server_socket.setblocking(False)
server_socket.listen(1024)