[nanomsg] AF_SP_RAW vs AF_SP

  • From: Drew Crawford <drew@xxxxxxxxxxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 5 May 2014 04:39:39 -0500

The documentation says

> Raw sockets omit the end-to-end functionality found in AF_SP sockets and thus 
> can be used to implement intermediary devices in SP topologies.

What exactly does this “end-to-end functionality” that is omitted consist of?  
I have grepped the source code to try and understand the effect of AF_SP_RAW 
and it’s not immediately clear.  

One thing I have noticed is that recv doesn’t seem to work on raw sockets.  The 
following code hangs indefinitely when use_raw = True:

> import nanomsg
> use_raw = True
> router = nanomsg.Socket(domain=nanomsg.AF_SP_RAW if use_raw else 
> nanomsg.AF_SP, protocol=nanomsg.REP)
> debug = nanomsg.Socket(domain=nanomsg.AF_SP, protocol=nanomsg.REQ)
> router.bind("tcp://0.0.0.0:55555")
> debug.connect("tcp://localhost:55555")
> 
> 
> def client():
>     while True:
>         debug.send("ping")
>         print(debug.recv())
> 
> import threading
> thread = threading.Thread(target=client)
> thread.start()
> 
> while True:
>     print(router.recv())
>     router.send("pong")


The difference in behavior for raw sockets that causes this behavior is not 
immediately clear.

Drew

Other related posts: