SocketServer#
- class lsst.ts.ess.common.SocketServer(name, host, port, log, simulation_mode=0, connect_callback=None)#
Bases:
OneClientReadLoopServerA socket server for exchanging JSON messages via TCP/IP.
See
tcpip.OneClientReadLoopServerfor the inner workings.- Parameters:
name (
str) – The name of the socket server.host (
strorNone) – IP address for this server. IfNonethen bind to all network interfaces.port (
int) – IP port for this server. If 0 then use a random port.simulation_mode (
int, optional) – Simulation mode. The default is 0: do not simulate.log (
Logger)connect_callback (
Optional[Callable[[BaseClientOrServer],Awaitable[None]]], default:None)
Attributes Summary
Methods Summary
close_client(**kwargs)Stop sending telemetry and close the client.
Read, parse, and dispatch one item of data.
set_command_handler(command_handler)Set the command handler instance to use.
Attributes Documentation
- valid_simulation_modes = (0, 1)#
Methods Documentation
- async close_client(**kwargs)#
Stop sending telemetry and close the client.
- async read_and_dispatch()#
Read, parse, and dispatch one item of data.
Subclasses need to implement this method such that it reads and parses data and then dispatches handling the data to a method suitable for the subclass. Methods that might be helpful include: :rtype:
Noneread_jsonto read json-encoded dataread_strto read terminated stringsread_intoto read binary structs
- set_command_handler(command_handler)#
Set the command handler instance to use. All code using this SocketServer class must call this at least once before sending commands.
- Parameters:
command_handler (
AbstractCommandHandler) – The command handler instance to use.- Return type: