antipattern
antipattern

Reputation: 780

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?

Upvotes: 2

Views: 1871

Answers (2)

user907323
user907323

Reputation: 50

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.

Upvotes: 3

antipattern
antipattern

Reputation: 780

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.

Upvotes: 1

Related Questions