[nanomsg] Asynchronous (raw) sockets in nanomsg

  • From: Paul Colomiets <paul@xxxxxxxxxxxxxx>
  • To: "nanomsg@xxxxxxxxxxxxx" <nanomsg@xxxxxxxxxxxxx>
  • Date: Fri, 15 Nov 2013 17:28:29 +0200

Hi,

I'm trying to make integration tests for nanomsg. The fact is that
most reasonable integration tests need many simultaneous requests, so
I need to use raw sockets and reimplement the whole request-reply
state machine for the task. Same problem has been solved in
nanoconfig.

The outcome is that request-reply state machine will be reimplemented
in many different frameworks and applications, probably with different
characteristics. Here is a short summary of complexities for every
implementation:

1. Request id, random number generator: it's too attractive to use C
random or something similar

2. Request repeating: it's too easy to forget about it

3. It's not possible to repeat request on reconnect (github issues #86, #87)

4. recv() cuts request id, if its first in message (it's a bug that
should probably be solved with recvmsg, but anyway), so you need to
add additional useless pipe id by application.

5. Even for simple tasks like "send 10 requests, receive 10 replies"
you need a NN_RCVFD and some kind of poll/select

(BTW: I've implemented asynchronous requests multiple times using XREQ
for zeromq multiple times, but zeromq has no issue with items 4,5 and
items 1-3 are there for REQ sockets too).

There are many ways to fix the situation:

1. Implement functionality on top of nanomsg, along with async main
loop (aka czmq)

2. Implement functionality in high level language bindings (each of them)

3. Implement functionality in nanomsg itself:
 a) using sendmsg/recvmsg
 b) add AF_SP_ASYNC protocol family

Any preferences? Thoughts?

-- 
Paul

Other related posts: