mirror of
https://github.com/python/cpython.git
synced 2025-01-19 23:15:20 +08:00
Add class variable allow_reuse_address in TCPServer -- if nonzero, the
server_bind() method calls setsockopt(SOL_SOCKET, SO_REUSEADDR, 1).
This commit is contained in:
parent
fd4114e7b8
commit
e3c7a5fbf5
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user