zeromq / cppzmq

Header-only C++ binding for libzmq
http://www.zeromq.org
MIT License
1.97k stars 757 forks source link

Cannot receive message using PGM protocal #483

Open mercerme opened 3 years ago

mercerme commented 3 years ago

Using a pub-sub model to send and receive message, the Wireshark can get the PGM package on my subscriber computer, but the subscriber seems to stop at const int nbytes =zmq_msg_recv(msg.handle(), _handle, static_cast(flags));

The code of publisher is :zmq::socket_t publisher(*ctx, zmq::socket_type::pub); publisher.bind("pgm://224.0.0.1:1682"); std::this_thread::sleep_for(std::chrono::milliseconds(200)); char test[256]={0}; while(1){ publisher.send(zmq::str_buffer(test)); }

The code of subscriber is :'zmq::socket_t subscriber(*ctx, zmq::socket_type::sub); const char* addr = "pgm://192.168.1.139;224.0.0.1:1682"; subscriber.connect(addr); subscriber.set(zmq::sockopt::subscribe, ""); while(1){ zmq::message_t msg; subscriber.recv(msg); std::cout<<"having received message"<<std::endl;

pengfengyong commented 1 year ago

Hello,did you resolved this problem? I meet the same question.