I have two machines in the same network :
The first machine binds to a socket on its own IP address (
120.0.0.1
) and receives any data coming to the socket.bind()
-ed on port5555
:zmq::context_t context{1}; zmq::socket_t socket{context, ZMQ_SUB}; socket.setsockopt(ZMQ_SUBSCRIBE, "lidar"); socket.bind("tcp://120.0.0.1:5555"); while(true) { zmq::message_t message; auto recv = socket.recv(message); ROS_INFO("Value: %d", recv.value()); }
The second machine, having an IP address
120.0.0.248
, connects to the first machine and sends the messages to it:sock.connect("tcp://120.0.0.1:5555"); while (1) { double nodes[8192]; sock.send(zmq::buffer("lidar") , zmq::send_flags::sndmore); sock.send(zmq::buffer(nodes, (((int)(count)) * 8))); }
But for some reason, I cannot receive any messages on the first machine and it gets stuck on auto recv = socket.recv(message);
.
What is a correct way for such communication?