[nanomsg] Re: AF_SP_RAW vs AF_SP

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 05 May 2014 12:07:24 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

For understanding how it works, read the REQ/REP RFC:

https://raw.githubusercontent.com/nanomsg/nanomsg/master/rfc/sp-request-reply-01.txt

However, as a user you can use the rule of thumb: Use standard sockets
if you are going to use the socket yourself. Use RAW sockets to be
passed to nn_device().

Martin

On 05/05/14 11:39, Drew Crawford wrote:
> 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
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTZ2LcAAoJENTpVjxCNN9YB4gH/20GlDQqvCGP2Mtz+9WP522v
fcoAM70+4hPtT5DY92Fwbu1Qm5FGhE7idtuKPy7qfcEyGJ1kAivwnslU3+k+v9Rr
cVJZl0intzcUXYSG5KUPR68aBuo+9ppIkbM9PfA2Z181JqHlz6Ew0VvPGBPjWAcG
IXAL7bbKx1wKxD+hUCy8BYvodNbTRNSf6vg2XnDVS11nsYx9kwAjDXrvciTxdwXs
TMYJ1aQBSSRCrOL+LbWGX2HsLwUp2MEVdpov7+Ii4BncnemrYkG977mI0FiKtLZ3
HQK6AP8aOhSD92tEO2G2mOkpJF6MYmar3WMt6k894elPapexEz8SSY6/TofsQbw=
=HtBg
-----END PGP SIGNATURE-----

Other related posts: