我有一个创建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的服务器