nnpy
nnpy copied to clipboard
sendmsg and recvmsg
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 fromnn_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
.