zeromq / cppzmq

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

ZMQ_RADIO "udp://*:6600", The protocol is not compatible with the socket type #549

Open Durant35 opened 2 years ago

Durant35 commented 2 years ago

 I have built https://github.com/zeromq/libzmq/releases/tag/v4.3.4 as following:

./autogen.sh
./configure --prefix=`pwd`/install --enable-drafts
make install

 Besides, I use https://github.com/zeromq/cppzmq/releases/tag/v4.8.1 and the codes as followings:

// .hpp
...
zmq::context_t zmq_context_;
...
std::shared_ptr<zmq::socket_t> zmq_camera_;
...

// .cpp
// camera socket
 zmq_camera_ = std::make_shared<zmq::socket_t>(zmq_context_, ZMQ_RADIO);
...
const std::string &camera_publish_address =
        "udp://*:" +
        std::to_string(camera_config.cameras[0].publish_port);
std::cout << "Camera publish at " << camera_publish_address << std::endl;
zmq_camera_->bind(camera_publish_address);
...

 However, it runs with crash:

...
Camera publish at udp://*:6600
terminate called after throwing an instance of 'zmq::error_t'
  what():  The protocol is not compatible with the socket type
...
Durant35 commented 2 years ago

int main (void) { void *ctx = zmq_ctx_new (); assert (ctx);

void *radio = zmq_socket (ctx, ZMQ_RADIO);
void *dish = zmq_socket (ctx, ZMQ_DISH);

int rc = zmq_bind (radio, "udp://192.168.4.102:6600");
assert (rc == 0);

rc = zmq_connect (dish, "udp://192.168.4.102:6600");
assert (rc == 0);

zmq_sleep (1);

rc = zmq_close (dish);
assert (rc == 0);

rc = zmq_close (radio);
assert (rc == 0);

rc = zmq_ctx_term (ctx);
assert (rc == 0);

return 0 ;

}