I am trying to make a class that will be able to send data and then receive them.
Right now, it is working only for the first send/receive and with another attempt to .send()
it will throw an error below.
>Traceback (most recent call last):
File "main.py", line 31, in <module>
zq.send(arr)
File "D:\ITIM\video2\MQCompare\cZMQ.py", line 17, in send
self.socketC.send(data)
File "zmq/backend/cython/socket.pyx", line 636, in zmq.backend.cython.socket.S
ocket.send (zmq\backend\cython\socket.c:7305)
File "zmq/backend/cython/socket.pyx", line 683, in zmq.backend.cython.socket.S
ocket.send (zmq\backend\cython\socket.c:7048)
File "zmq/backend/cython/socket.pyx", line 206, in zmq.backend.cython.socket._
send_copy (zmq\backend\cython\socket.c:3032)
File "zmq/backend/cython/socket.pyx", line 201, in zmq.backend.cython.socket._
send_copy (zmq\backend\cython\socket.c:2920)
File "zmq/backend/cython/checkrc.pxd", line 25, in zmq.backend.cython.checkrc.
_check_rc (zmq\backend\cython\socket.c:10014)
raise ZMQError(errno)
zmq.error.ZMQError: Operation cannot be accomplished in current state`
The code I'm using looks like this:
import zmq
class ZeroMQ:
def __init__(self):
self.context = zmq.Context()
self.socketS = self.context.socket(zmq.REP)
self.socketS.bind("tcp://*:5555")
self.socketC = self.context.socket(zmq.REQ)
self.socketC.connect("tcp://localhost:5555")
def __exit__(self, exc_type, exc_value, traceback):
self.socketC.close()
self.socketS.close()
def send(self, data):
self.socketC.send(data)
def recv(self):
self.socketS.recv()
Am I making the connection right?
Why is the function send throwing an error?
I will appreciate any help. Thank you.