Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

sendmsg and recvmsg #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

sendmsg and recvmsg #43

wants to merge 2 commits into from

Conversation

gwangyi
Copy link

@gwangyi gwangyi commented Feb 8, 2017

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.

* `struct nn_msghdr`
* `struct nn_cmsghdr`
* `struct nn_iovec`
* `NN_CMSG_FIRSTHDR`
* `NN_CMSG_NXTHDR`
* `NN_CMSG_DATA`
* `NN_CMSG_SPACE`
* `NN_CMSG_LEN`
`nn_recvmsg` returns tuple consist of received data and control headers.
`nn_sendmsg` takes data which will be sended and control headers which is taken from `nn_recvmsg`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant