Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #server.py
- import nnpy, time
- pub = nnpy.Socket(nnpy.AF_SP, nnpy.PUB)
- pub.bind('ipc://testing2')
- while(True):
- time.sleep(5)
- print("Server is sleeping again.")
- #publisher.py
- import nnpy, time
- pub = nnpy.Socket(nnpy.AF_SP, nnpy.PUB)
- pub.connect('ipc://testing2')
- while(True):
- time.sleep(5)
- print("Publisher about to send...")
- pub.send("foobar")
- #subscriber.py
- import nnpy, time
- sub = nnpy.Socket(nnpy.AF_SP, nnpy.SUB)
- sub.connect('ipc://testing2')
- sub.setsockopt(nnpy.SUB, nnpy.SUB_SUBSCRIBE, '')
- while(True):
- time.sleep(5)
- print("Subscriber about to recv")
- print(sub.recv())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement