Socket¶
- class dsviper.Socket¶
Bases:
objectA passive socket for a server: bound by its factory, listened on by the server it is handed to.
Only the passive factories a server needs are exposed: the active side, the socket options and the I/O surface stay internal.
On macOS and Linux a unix socket path is limited to about 104 bytes; a longer one fails to bind, reporting that the address is already in use.
Note: Not directly instantiable. Use create_passive_local() or create_passive_inet().
- close() None¶
Release the socket.
A passive local socket is a file on disk, and deallocation only happens when the last reference goes away, which a host cannot always predict. A host that abandons a socket – a failed bind, a reconfiguration, a shutdown – says so with this. Idempotent.
- static create_passive_inet(host: str, service: str) Socket¶
Return a socket bound to host and service, over TCP.
service is a port number or a service name, as a str. The socket is bound, not yet listening: the server it is handed to listens on it. Nothing reads the port back, so a service of ‘0’, which lets the system choose one, leaves the caller unable to tell a client where to connect.
- static create_passive_local(socket_path: str) Socket¶
Return a socket bound to the unix socket socket_path.
It is bound, not yet listening: the server it is handed to listens on it.
- is_closed() bool¶
Return True once the socket has been released.