MCPcopy Index your code
hub / github.com/python/cpython / server_bind

Method server_bind

Lib/socketserver.py:460–476  ·  view source on GitHub ↗

Called by constructor to bind the socket. May be overridden.

(self)

Source from the content-addressed store, hash-verified

458 raise
459
460 def server_bind(self):
461 """Called by constructor to bind the socket.
462
463 May be overridden.
464
465 """
466 if self.allow_reuse_address and hasattr(socket, "SO_REUSEADDR"):
467 self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
468 # Since Linux 6.12.9, SO_REUSEPORT is not allowed
469 # on other address families than AF_INET/AF_INET6.
470 if (
471 self.allow_reuse_port and hasattr(socket, "SO_REUSEPORT")
472 and self.address_family in (socket.AF_INET, socket.AF_INET6)
473 ):
474 self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
475 self.socket.bind(self.server_address)
476 self.server_address = self.socket.getsockname()
477
478 def server_activate(self):
479 """Called by constructor to activate the server.

Callers 1

__init__Method · 0.95

Calls 3

setsockoptMethod · 0.45
bindMethod · 0.45
getsocknameMethod · 0.45

Tested by

no test coverage detected