TCP, UDP and RAW socket. Cannot be created directly. Instead, call
Provides a subset of CPython’s
socket.socketAPI. It only implements the versions of recv that do not allocate bytes objects.
No-op used by Context Managers.
Automatically closes the Socket when exiting a context. See Lifetime and ContextManagers for more info.
Closes this Socket and makes its resources available to its SocketPool.
connect(self, address: tuple)¶
Connect a socket to a remote address
Parameters: address (~tuple) – tuple of (remote_address, remote_port)
send(self, bytes: ReadableBuffer)¶
Send some bytes to the connected remote address. Suits sockets of type SOCK_STREAM
Parameters: bytes (~bytes) – some bytes to send
recv_into(self, buffer: WriteableBuffer, bufsize: int)¶
Reads some bytes from the connected remote address, writing into the provided buffer. If bufsize <= len(buffer) is given, a maximum of bufsize bytes will be read into the buffer. If no valid value is given for bufsize, the default is the length of the given buffer.
Suits sockets of type SOCK_STREAM Returns an int of number of bytes read.
settimeout(self, value: int)¶
Set the timeout value for this socket.
Parameters: value (~int) – timeout in seconds. 0 means non-blocking. None means block indefinitely.
Returns a hash for the Socket.
A pool of socket resources available for the given radio. Only one SocketPool can be created for each radio.
SocketPool should be used in place of CPython’s socket which provides a pool of sockets provided by the underlying OS.
getaddrinfo(host: str, port: int, family: int = 0, type: int = 0, proto: int = 0, flags: int = 0) → tuple¶
Gets the address information for a hostname and port
Returns the appropriate family, socket type, socket protocol and address information to call socket.socket() and socket.connect() with, as a tuple.