Skip to content

Commit

Permalink
Allow for configurable IP and port when instantiating ZMQClient
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-oqc committed Nov 8, 2024
1 parent 47771e4 commit e2451d5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 40 deletions.
68 changes: 34 additions & 34 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "qat-rpc"
version = "0.4.0"
version = "0.5.0"
description = "RPC tooling for OQC QAT."
authors = ["Kajsa Eriksson Rosenqvist <[email protected]>"]
readme = "README.md"
Expand Down
19 changes: 14 additions & 5 deletions src/QAT_RPC/qat_rpc/zmq/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ class Messages(Enum):


class ZMQBase:
def __init__(self, socket_type: zmq.SocketType):
def __init__(
self,
socket_type: zmq.SocketType,
ip_address: str = "127.0.0.1",
port: str = "5556"
):
self._context = zmq.Context()
self._socket = self._context.socket(socket_type)
self._timeout = 30.0
self._protocol = "tcp"
self._ip_address = "127.0.0.1"
self._port = "5556"
self._ip_address = ip_address
self._port = port

@property
def address(self):
Expand Down Expand Up @@ -155,8 +160,12 @@ def stop(self):


class ZMQClient(ZMQBase):
def __init__(self):
super().__init__(zmq.REQ)
def __init__(
self,
ip_address: str = "127.0.0.1",
port: str = "5556"
):
super().__init__(zmq.REQ, ip_address, port)
self._socket.setsockopt(zmq.LINGER, 0)
self._socket.connect(self.address)

Expand Down

0 comments on commit e2451d5

Please sign in to comment.