bpod_core.ipc.DualChannelHost

class bpod_core.ipc.DualChannelHost

Bases: DualChannelBase

A ZeroMQ host providing REQ/REP and PUB/SUB sockets with Zeroconf discovery.

__init__(service_name, service_type, txt_record=None, event_handler=None, remote=True, port_pub=None, port_rep=None, serialization='msgpack') None

Initialize the DualChannelHost.

Parameters:
  • service_name (str) – Service name to advertise.

  • service_type (str) – Zeroconf service type (e.g., ‘my_service’).

  • txt_record (dict, optional) – Additional TXT records for Zeroconf service advertisement.

  • event_handler (callable, optional) – Function to handle incoming requests.

  • remote (bool, default True) – If True, binds TCP sockets to ‘0.0.0.0’. Otherwise, binds to ‘127.0.0.1’.

  • port_pub (int, optional) – TCP port to bind the PUB socket. If None, a random available port is chosen.

  • port_rep (int, optional) – TCP port to bind the REP socket. If None, a random available port is chosen.

  • serialization ({'json', 'msgpack'}, default 'msgpack') – Serialization format for message encoding.

Return type:

None

close() bool

Close the host and clean up resources.

Returns:

True if the host closed successfully, False otherwise.

Return type:

bool