简体   繁体   中英

Call to zmq_socket returns NULL and errno 14 (Bad address)

I am working on a test client/server application using ZeroMQ x86 for connectivity on Windows 8, VS 2012. Unfortunately, I have some trouble with initializing a connection. For now I simply copied (and slightly extended with error reporting) the example hwserver.c and use following code to initialize:

void* ctx;
void* rsp;
ctx = zmq_ctx_new();
DWORD dwErr = zmq_errno();
printf("Creating Context - %s\r\n", zmq_strerror(dwErr));

rsp = zmq_socket(ctx, ZMQ_REP);
dwErr = zmq_errno();
printf("Creating Socket - %s\r\n", zmq_strerror(dwErr));

This fails at the call to zmq_socket which returns rsp == NULL and dwErr==14 : Bad address. Given that this is nearly identical to the example code and yet it fails I'm out of answers. Maybe someone has an idea what is wrong with that call. Maybe it is a compatibility issue with using 32bit binaries?

I experienced a similar issue when I accidentally installed an old version of libzmq on my system. Once I removed it and installed a newer version, the problem went away.

So, after a good amount of debugging and trying to reproduce the error in new Projects, i've come up with following solution:

libzmq.lib has to be the first entry of all the .lib's that are about to be linked vs. the project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM