Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #server.py
  2. import nnpy, time
  3. pub = nnpy.Socket(nnpy.AF_SP, nnpy.PUB)
  4. pub.bind('ipc://testing2')
  5.  
  6. while(True):
  7. time.sleep(5)
  8. print("Server is sleeping again.")
  9.  
  10. #publisher.py
  11. import nnpy, time
  12.  
  13. pub = nnpy.Socket(nnpy.AF_SP, nnpy.PUB)
  14. pub.connect('ipc://testing2')
  15.  
  16. while(True):
  17. time.sleep(5)
  18. print("Publisher about to send...")
  19. pub.send("foobar")
  20.  
  21. #subscriber.py
  22. import nnpy, time
  23.  
  24. sub = nnpy.Socket(nnpy.AF_SP, nnpy.SUB)
  25. sub.connect('ipc://testing2')
  26. sub.setsockopt(nnpy.SUB, nnpy.SUB_SUBSCRIBE, '')
  27.  
  28. while(True):
  29. time.sleep(5)
  30. print("Subscriber about to recv")
  31. print(sub.recv())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement