-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
30 lines (24 loc) · 780 Bytes
/
server.py
File metadata and controls
30 lines (24 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import zmq
import random
from time import sleep
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind('tcp://127.0.0.1:2000')
while True:
face = "Facepalmer"
randNumber = random.randrange(0,999999)
# This guy should show up to the client
socket.send("ARNOLD %s %d" % (face, randNumber))
# This will be dropped by the client as it's
# filtering messages where ARNOLD is the first
# string
socket.send("FACEPALMER ARNOLD %s %d" % (face,
randNumber))
# This will also show up in the client as the
# filter is simply checking to see that the pattern
# matches the front of the string, you would need
# to add a space to the consumer's filter to make
# this message get dropped
socket.send("ARNOLDFACEPALMER %s %d" % (face,
randNumber))
sleep(1)