[zeromq-dev] PUB/SUB not sending data

Raúl Parada Medina raul.parada.medina at gmail.com
Wed Nov 22 13:14:46 CET 2023


Hi,

I'm sending data in python between two connect machines within the same
network (successfully connected).

The publisher code is defined as:

def senderzmq(self, lat, lon):
    sock = zmq.Context().socket(zmq.PUB)
    sock.bind("tcp://*:10000")
    running = True
    while running:
        sock.send_string(f"Lat {lat}, Lon={lon}")


The receiver has the following format:

import zmq
context=zmq.Context()
socket=context.socket(zmq.SUB)
socket.connect("tcp://192.168.1.35:10000")
while True:
         message=socket.recv_string()
         print(message)

The above development works, however, the sender always sends the same
data, it looks the sender remains within the while True state not listening
new data. If I remove the while True, the above doesn't work. Any idea how
to exit the while True but transmitting new data at each loop?

Thanks.
Raúl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20231122/1a7044c8/attachment.htm>


More information about the zeromq-dev mailing list