SocketServer#

class lsst.ts.ess.common.SocketServer(name, host, port, log, simulation_mode=0, connect_callback=None)#

Bases: OneClientReadLoopServer

A socket server for exchanging JSON messages via TCP/IP.

See tcpip.OneClientReadLoopServer for the inner workings.

Parameters:
  • name (str) – The name of the socket server.

  • host (str or None) – IP address for this server. If None then 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_and_dispatch()

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.

Parameters:

kwargs (Any)

Return type:

None

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: None

  • read_json to read json-encoded data

  • read_str to read terminated strings

  • read_into to 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:

None