Functions
create_listener
1
socket.socket
▼
Create and bind a single server socket from configuration.
If ``config.uds`` i…
create_listener
1
socket.socket
▼
def create_listener(config: ServerConfig) -> socket.socket
Create and bind a single server socket from configuration.
Ifconfig.udsis set, creates a Unix domain socket.
Otherwise creates a TCP socket bound toconfig.host:config.port.
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
Server configuration with host, port, and backlog settings. |
Returns
socket.socket
create_listeners
2
list[socket.socket]
▼
Create server sockets for *count* workers.
On platforms with ``SO_REUSEPORT`` …
create_listeners
2
list[socket.socket]
▼
def create_listeners(config: ServerConfig, count: int) -> list[socket.socket]
Create server sockets for count workers.
On platforms withSO_REUSEPORTeach worker gets its own
independently bound socket so the kernel distributes connections.
WhenSO_REUSEPORTis unavailable, a single socket is created and
the same object is returned for every worker (shared-fd strategy).
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
Server configuration. |
count |
int |
Number of worker sockets needed. |
Returns
list[socket.socket]
has_so_reuseport
0
bool
▼
Check if SO_REUSEPORT is available on this platform.
has_so_reuseport
0
bool
▼
def has_so_reuseport() -> bool
Returns
bool
_bind_unix_socket
1
socket.socket
▼
Create, bind, and listen on a Unix domain socket.
Removes any stale socket fil…
_bind_unix_socket
1
socket.socket
▼
def _bind_unix_socket(config: ServerConfig) -> socket.socket
Create, bind, and listen on a Unix domain socket.
Removes any stale socket file before binding. The socket file
should be cleaned up on shutdown viacleanup_unix_socket().
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
Returns
socket.socket
cleanup_unix_socket
1
None
▼
Remove the Unix domain socket file on shutdown.
Safe to call even if no UDS is…
cleanup_unix_socket
1
None
▼
def cleanup_unix_socket(config: ServerConfig) -> None
Remove the Unix domain socket file on shutdown.
Safe to call even if no UDS is configured (no-op).
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
_bind_socket
1
socket.socket
▼
Create, configure, bind, and listen on a single TCP socket.
Uses ``getaddrinfo…
_bind_socket
1
socket.socket
▼
def _bind_socket(config: ServerConfig) -> socket.socket
Create, configure, bind, and listen on a single TCP socket.
Usesgetaddrinfoto resolve the host, supporting both IPv4 and
IPv6 addresses. When binding to an IPv6 address, enables dual-stack
(IPV6_V6ONLY=False) where possible so both IPv4 and IPv6 clients
can connect.
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
Returns
socket.socket