[nanomsg] Re: AF_SP_RAW vs AF_SP

  • From: zerotacg <zero@xxxxxxxxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 05 May 2014 23:26:36 +0200

the behavior of raw sockets is more or less the same as ZeroMQ

for your example a raw REP is similar to the DEALER in ZeroMQ
so you are responsible to grab the pipe id from the message and add it
again when responding, you shouldn't do a simple recv but recv msg
to get the headers (or equivalent for your binding)

Tobi

On 05.05.2014 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
> 


Other related posts: