Merge remote-tracking branch 'origin/dev' into feat/actuation-receiver

# Conflicts:
#	src/robot_interface/endpoints/socket_base.py
This commit is contained in:
Twirre Meulenbelt
2025-10-16 17:01:16 +02:00
4 changed files with 67 additions and 1 deletions

View File

@@ -25,7 +25,7 @@ class SocketBase(object):
self.socket = None # Set later by `create_socket`
self.bound = None # Set later by `create_socket`
def create_socket(self, zmq_context, socket_type, port, bind=True):
def create_socket(self, zmq_context, socket_type, port, options=[], bind=True):
"""
Create a ZeroMQ socket.
@@ -38,11 +38,19 @@ class SocketBase(object):
:param port: The port to use.
:type port: int
:param options: A list of options to be set on the socket. The list contains tuples where the first element contains the option
and the second the value, for example (zmq.CONFLATE, 1).
:type options: list[tuple[int, int]]
:param bind: Whether to bind the socket or connect to it.
:type bind: bool
"""
self.port = port
self.socket = zmq_context.socket(socket_type)
for option, arg in options:
self.socket.setsockopt(option,arg)
self.bound = bind
if bind:
self.socket.bind("tcp://*:{}".format(port))