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. Local advertisement uses theLocalServiceAdvertisementclass. Whenremote=True, the service is additionally advertised via Zeroconf (mDNS) for network-wide discovery and remote-process communication.- Parameters:
service_name (
str) – Service name to advertise.service_type (
str) – Service type.properties (
dict, optional) – Additional properties for service advertisement.uuid (
UUID, optional) – UUID for local IPC. Will be generated if not provided.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’.