nnpy icon indicating copy to clipboard operation
nnpy copied to clipboard

sendmsg and recvmsg

Open gwangyi opened this issue 8 years ago • 0 comments

To implement async rep socket, in my knowledge, there are two ways.

  • We can make multiple rep workers at same time. It can serve a request which is sent before replying preceding requests. However, if a req socket is connected to multiple rep sockets, request-receiving rep socket is chosen by round-robin algorithm. If one of rep workers is stuck forever, any one of requests cannot be served eventually.
  • We can use raw rep socket. To correctly reply to a request, we need to use nn_sendmsg with the control header which is taken from nn_recvmsg. Raw rep sockets can recv one or more requests consequently and serve completely out of order.

For that reason, I implemented sendmsg and recvmsg in nnpy.Socket.

gwangyi avatar Feb 08 '17 05:02 gwangyi