我有一个创建 zmq REQ 套接字并发送一些数据的程序,由于某种原因,数据仅在DllMain
(在 msgbox 4 之后)而不是在zmq_send()
.
void client_init(void *z_socket) {
assert(z_socket == NULL);
void *context = NULL;
zmq_msg_t send_msg;
zmq_msg_init_data(&send_msg, "asdf", 4, NULL, NULL);
context = zmq_init(10);
MessageBox(NULL, "msg1", "yes", 1);
z_socket = zmq_socket(context, ZMQ_REQ);
assert(z_socket != NULL);
MessageBox(NULL, "msg2", "yes", 1);
assert(zmq_connect(z_socket, "tcp://127.0.0.1:3490") != -1);
zmq_send(z_socket, &send_msg2, 0);
MessageBox(NULL, "msg3", "yes", 1);
}
BOOL WINAPI DllMain(...) {
void *z_socket = NULL;
client_init(z_socket);
MessageBox(NULL, "msg4", "yes", 1);
return TRUE;
}
为什么会发生???
顺便说一句,我使用 pyzmq 作为侦听端口 3490 的服务器