diff options
author | Guido van Rossum <guido@python.org> | 2000-05-09 14:53:29 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-05-09 14:53:29 (GMT) |
commit | e3c7a5fbf5b737666a3e1f58f0677ec93e4de032 (patch) | |
tree | 2a81a0e90f06f3b300fb14adf2400b9163e90ed2 | |
parent | fd4114e7b8d7c81931b488aa11157261c2958b71 (diff) | |
download | cpython-e3c7a5fbf5b737666a3e1f58f0677ec93e4de032.zip cpython-e3c7a5fbf5b737666a3e1f58f0677ec93e4de032.tar.gz cpython-e3c7a5fbf5b737666a3e1f58f0677ec93e4de032.tar.bz2 |
Add class variable allow_reuse_address in TCPServer -- if nonzero, the
server_bind() method calls setsockopt(SOL_SOCKET, SO_REUSEADDR, 1).
-rw-r--r-- | Lib/SocketServer.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py index 2c73356..5562fb0 100644 --- a/Lib/SocketServer.py +++ b/Lib/SocketServer.py @@ -141,6 +141,7 @@ class TCPServer: - address_family - socket_type - request_queue_size (only for stream sockets) + - reuse_address Instance variables: @@ -156,6 +157,8 @@ class TCPServer: request_queue_size = 5 + allow_reuse_address = 0 + def __init__(self, server_address, RequestHandlerClass): """Constructor. May be extended, do not override.""" self.server_address = server_address @@ -171,6 +174,8 @@ class TCPServer: May be overridden. """ + if self.allow_reuse_address: + self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.socket.bind(self.server_address) def server_activate(self): |