1

I am trying to write a surveyor respondent pattern. But it throws the error:

nanomsg.NanoMsgAPIError: Operation cannot be performed in this state

from nanomsg import *

s1 = Socket(SURVEYOR)
s1.bind('ipc://bob')
s1.send(b'hello nanomsg')
print(s1.recv())
s1.close()

from nanomsg import *

s2 = Socket(RESPONDENT)
s2.connect('ipc://bob')
print(s2.recv())
s2.send(b'Hello')
s2.close()

How can I implement this pattern in python?

sg7
  • 6,108
  • 2
  • 32
  • 40
Davoud Taghawi-Nejad
  • 16,142
  • 12
  • 62
  • 82

1 Answers1

0

Its a bug, it can be circumvented by inserting "time.sleep(0.1)", after the bind or connect statement.

from nanomsg import *
import time


s1 = Socket(SURVEYOR)
s1.bind('ipc://bob.ipc')
time.sleep(0.1)
s1.send(b'hello nanomsg')
print(s1.recv())
s1.close()
Davoud Taghawi-Nejad
  • 16,142
  • 12
  • 62
  • 82