ZMQ_HELLO_MSG doesn't work
wsehjk opened this issue · 0 comments
wsehjk commented
Please use this template for reporting suspected bugs or requests for help.
Issue description
server socket (router mode) set the ZMQ_HELLO_MSG, but the client (dealer mode) cannnot receive this msg, even though netstat
says connection has been established.
Environment
- libzmq version (commit hash if unreleased): 4.3.4
- OS: macos Monterey 12.5.1, vscode 1.84.2 (Universal)
Minimal test code / Steps to reproduce the issue
#define ZMQ_BUILD_DRAFT_API
#include <iostream>
#include <zmq.hpp>
int main() {
zmq::context_t server_ctx;
zmq::context_t client_ctx;
zmq::socket_t server(server_ctx, zmq::socket_type::router);
zmq::socket_t client(client_ctx, zmq::socket_type::dealer);
zmq_setsockopt(server, ZMQ_HELLO_MSG, "hello", 5);
client.setsockopt(ZMQ_RCVTIMEO, 80000); // 500ms
server.bind("tcp://127.0.0.1:5555");
client.connect("tcp://127.0.0.1:5555");
zmq::message_t msg;
while (true) {
client.recv(msg);
if (!msg.empty()) {
std::string str(msg.to_string());
std::cout << str << std::endl;
break;
}
}
return 0;
}
What's the actual result? (include assertion message & call stack if applicable)
should print hello
What's the expected result?
program stuck in the while
loop