Server classes

Each server has a corresponding connection, which is created automatically when a new connection is made.

SocketServer

This is a low-level socket server which reads and writes bytes.

class mara.servers.socket.SocketServer(host: str = '127.0.0.1', port: int = 9000, ssl: ssl.SSLContext | None = None, ssl_cert: str | pathlib.Path | None = None, ssl_key: str | pathlib.Path | None = None)

Bases: AbstractSocketServer

connection_class

alias of SocketConnection

class mara.servers.socket.SocketConnection(server: AbstractServer, reader: asyncio.StreamReader, writer: asyncio.StreamWriter)

Bases: SocketMixin, AbstractConnection[bytes]

Read and write bytes

TextServer

This wraps the SocketServer to read and write text str.

class mara.servers.socket.TextServer(host: str = '127.0.0.1', port: int = 9000, ssl: ssl.SSLContext | None = None, ssl_cert: str | pathlib.Path | None = None, ssl_key: str | pathlib.Path | None = None)

Bases: AbstractSocketServer

connection_class

alias of TextConnection

class mara.servers.socket.TextConnection(server: AbstractServer, reader: asyncio.StreamReader, writer: asyncio.StreamWriter)

Bases: SocketMixin, AbstractConnection[str]

Read and write unicode over an underlying byte socket

write(data: str, *, end: str = '\r\n')

Write to the outbound queue