nanomsg / nnpy

cffi-based Python bindings for nanomsg
MIT License
117 stars 39 forks source link

Is there a plan for supporting nn_recvmsg, nn_sendmsg in Socket class? #42

Open gwangyi opened 7 years ago

gwangyi commented 7 years ago

I want to implement async rep/req pattern, but there's no nn_recvmsg/nn_sendmsg supports in nnpy.

In my understanding, async rep/req needs AF_SP_RAW socket and nn_recvmsg/nn_sendmsg with nn_msghdr::msg_control field.

Do you have any plan about supporting nn_recvmsg/nn_sendmsg?

djc commented 7 years ago

I'm not sure what you need the msg_control for, from what I know just using AF_SP_RAW should be sufficient. Why do you think you need it?

There are no current plans, but I'd be open to adding this. Particularly if you can contribute code changes. ;)

gwangyi commented 7 years ago

I found the example of async rep/req pattern at nanomsg/demo/async_demo.c. In this example, it creates REP socket with with AF_SP_RAW and stores msg_control which is gained from nn_recvmsg. After that, by using nn_sendmsg with stored msg_control, it replies to each associated REQ socket with out of order.

I am a novice about nanomsg, so there can be another implementation of async REP/REQ pattern, but I couldn't find them out.

djc commented 7 years ago

My hypothesis is that, if you use AF_SP_RAW with the normal messaging APIs, you might not need this handling of the control flag. Maybe you should try that first.