I'm trying to create a system for collecting data sent I have two small scripts, a receiver.py, which should receive the data, and sender that should send it, for the moment I try with the 1-1 connection, but finally I need multiple senders and one receiver which would process the incoming data. I try to accomplish this using 0mq publisher/subscriber pattern.
#receiver.py
def receive():
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.setsockopt(zmq.SUBSCRIBE, 'Child:')
socket.bind('tcp://localhost:5000')
while True:
print 'Parent received: %s' % socket.recv()
receive()
#sender.py
def send(data):
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.connect('tcp://localhost:5000')
socket.send('Sender: %i' % data)
socket.close()
print "sent"
send(10)
When I start receiver.py it just waits for the data, doesn't receive anything when I run sender.py. I'd be grateful for suggestions, actually I'm not even sure if the publisher/subscriber is the best pattern for my scenario (multiple sensors sending data over the local network to one server for real time processing).