[nanomsg] nn_recv() hanging

  • From: Dirkjan Ochtman <dirkjan@xxxxxxxxxx>
  • To: nanomsg <nanomsg@xxxxxxxxxxxxx>
  • Date: Tue, 20 Aug 2013 20:39:25 +0200

I'm working on a cffi-based Python binding, but I'm stuck right now. I
have this code:

import nnpy, time

pub = nnpy.Socket(nnpy.AF_SP, nnpy.PUB)
pub.bind('inproc://foo')
print pub.getsockopt(nnpy.SOL_SOCKET, nnpy.DOMAIN)

sub = nnpy.Socket(nnpy.AF_SP, nnpy.SUB)
sub.connect('inproc://foo')

pub.send('FLUB')
print 'YEAH'
time.sleep(0.5)
print sub.recv()

However, this seems to hang on the sub.recv() call. The socket class
is implemented in the simplest mapping to nn_* functions you could
imagine, here's what the recv() method looks like:

    def recv(self, flags=0):
        buf = ffi.new('char[16384]')
        rc = nanomsg.nn_recv(self.sock, buf, 16384, flags)
        assert rc > 0, rc
        print rc, buf

So far, it prints YEAH and then just sits there. The send completes
correctly, returning 4. This happens with both the inproc and tcp
transports, on a modern Linux box.

Any hints?

Cheers,

Dirkjan

Other related posts: