OneClientServer

class lsst.ts.hexrotcomm.OneClientServer(name, host, port, log, connect_callback)

Bases: object

A TCP/IP socket server that serves a single client.

If additional clients try to connect they are rejected (the socket writer is closed).

Parameters:
name : str

Name used for error messages. Typically “Commands” or “Telemetry”.

host : str

IP address for this server.

port : int

IP port for this server. If 0 then use a random port.

log : logging.Logger

Logger.

connect_callback : callable or None

Synchronous function to call when a connection is made or dropped. It receives one argument: this OneClientServer.

Attributes Summary

connected Return True if a client is connected to this socket.

Methods Summary

call_connect_callback() Call the connect_callback if connection state has changed.
close() Close socket server and client socket and set the done_task done.
close_client() Close the connected client socket, if any.
set_reader_writer(reader, writer) Set self.reader and self.writer.
start() Start TCP/IP server.

Attributes Documentation

connected

Return True if a client is connected to this socket.

Methods Documentation

call_connect_callback()

Call the connect_callback if connection state has changed.

close()

Close socket server and client socket and set the done_task done.

Always safe to call.

close_client()

Close the connected client socket, if any.

set_reader_writer(reader, writer)

Set self.reader and self.writer.

Called when a client connects to this server.

Parameters:
reader : asyncio.SocketReader

Socket reader.

writer : asyncio.SocketWriter

Socket writer.

start()

Start TCP/IP server.