bpod_core.ipc.ServiceHost
- class bpod_core.ipc.ServiceHost
Bases:
ServiceBaseA ZeroMQ host providing REQ/REP and PUB/SUB sockets with service discovery.
Provides two communication channels: a REQ/REP channel for synchronous request-reply messaging and a PUB/SUB channel for broadcasting events to subscribers. Incoming requests are dispatched to a user-provided
event_handlercallback.The service is automatically advertised for discovery by
ServiceClient. It is advertised locally via a file in the user’s runtime directory for inter-process communication. Whenremote=True, the service is additionally advertised via Zeroconf (mDNS) for network-wide discovery and remote-process communication.- __init__(service_name, service_type, properties=None, event_handler=None, port_pub=None, port_rep=None, serialization='msgpack', *, remote=True) None
Initialize the ServiceHost.
- Parameters:
service_name (
str) – Service name to advertise.service_type (
str) – Service type.properties (
dict, optional) – Additional properties for service advertisement.event_handler (
callable, optional) – Function to handle incoming requests.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 (
str, default'msgpack') – Serialization format for message encoding.remote (
bool, defaultTrue) – If True, binds TCP sockets to ‘0.0.0.0’. Otherwise, binds to ‘127.0.0.1’.
- Return type:
None