0

Im looking for a way to call specific functions from one side of IPC.

assume this sample code:

socket = context.socket(zmq.REQ)
socket.connect("tcp://127.0.0.1:8000")
socket.send(resp)

i want specify the function which 'resp' will be forwarded to, is it possible? if not how could i do that?

user1229351
  • 1,985
  • 4
  • 20
  • 24
  • What do you mean by function? What do you want the receiver to do with `resp`? Does `resp` target a receiver uniquely? – raffian Aug 02 '13 at 02:29

1 Answers1

1

I might have misunderstood your goal here. But there is a way to send multipart messages using zmq, meaning you can easily add an extra field that you can test on the other side to figure out how to handle your data.

Have a look at socket.send_multipart and socket.recv_multipart. http://zeromq.github.io/pyzmq/api/zmq.html#zmq.Socket.send_multipart

Using these you can do something like: send_multipart(["description_of_data", data]) and use recv_multipart() to receive a list on the other side. You can check the first element and handle the data accordingly.

The question is a bit unclear, if what you meant was a way to address specific receivers, have a look at the router/dealer xrep/xreq socket types, they include a routing envelope where you can target specific endpoints if you know their identity.

StianE
  • 3,055
  • 20
  • 20