Hi Raúl,

I feel that your questions may imply a deeper misunderstanding than what
they ask directly so let me offer a few comments that hopefully gets to
the real problems.  Feel free to ask more.

Of course the "while True" loop in the sender will send only identical
copies of the same message (and will do so at a very high rate).

There is no "listen new data" feature that I can think of.

Any code that calls the senderzmq() will find that this function never
returns.

It seems senderzmq() should be rewritten to simply omit the "while True"
loop so that the caller may call it many times and each time with some
new values of lat and lon.

One concrete thing I notice in your code.  Your the SUB socket in the
receiver does not register any topic.  See:

  https://pyzmq.readthedocs.io/en/latest/api/zmq.html#zmq.Socket.subscribe

Because of that, I expect the call to recv_string() never returns.


-Brett.

Raúl Parada Medina <[email protected]> writes:

> 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
> _______________________________________________
> zeromq-dev mailing list
> [email protected]
> https://urldefense.com/v3/__https://lists.zeromq.org/mailman/listinfo/zeromq-dev__;!!P4SdNyxKAPE!FdPTbAQ8PU-86XJs4hElWe3bCxrehQdjDjBH4O0bBEi2pIuVDIcT8FEo2UiwWt8dgjvqYmU0y8Gy0XiNlliTOuM$

Attachment: signature.asc
Description: PGP signature

_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to