General discussion
zeromq-dev@lists.zeromq.org (Subscribe) (View archives)
This is a fairly high traffic list for general discussion, both for users and developers.
You need to be subscribed to post to this list.
This mailing list is also available on Gmane.
If you wish to ask for help for your ØMQ programming issues on this list, then please:
- Do not post code fragments greater than a few lines, but use a pastebin.
- Do provide a fully working minimal test case for any bug or issue you wish to report.
- Do note the operating system, ØMQ version, and other relevant aspects.
Announcements
zeromq-announce@lists.zeromq.org (Subscribe) (View archives)
This is a low traffic list for important announcements (new releases and so on).

The 0mq examples are, reasonably, all shown as sequences of calls directly in main(),
but for generic use I wanted to split up the work into small functions in a separate
'c' code file that could be called from main().
So i started by splitting up the calls into these three functions:
initZmqMsg( &zmqInfo );
a. lpzmqInfo->vpContext = zmq_init (1);
b. lpzmqInfo->vpSocket = zmq_socket (lpzmqInfo->vpContext, ZMQ_REQ);
sendZmqMsg( &zmqInfo, &zmqTrans );
c. zmq_msg_init_size (&lpzmqInfo->mtMsg, 5);
d. memcpy (zmq_msg_data (&lpzmqInfo->mtMsg), "Hello", 5);
e. zmq_connect (lpzmqInfo->vpSocket, "tcp://localhost:5555");
f. zmq_sendmsg (lpzmqInfo->vpSocket, &lpzmqInfo->mtMsg, 0);
g. zmq_msg_close (&lpzmqInfo->mtMsg);
termZmqMsg( &zmqInfo );
h. zmq_close (lpzmqInfo->vpSocket);
i. zmq_term (lpzmqInfo->vpContext)
To make this work I defined a structure to pass into the functions
as a parameter:
typedef struct ppmdbzmq_info {
void * vpContext;
void * vpSocket;
zmq_msg_t mtMsg;
char * cpMessage;
} PPMDB_ZMQ_INFO, *LPPPMDB_ZMQ_INFO;
Here's the problem :
A. when the vpSocket variable is passed in as a function parameter
struct member defined and declared externally:
- initZmqMsg(0 sets the lpzmqInfo->vpContext and lpzmqInfo->vpSocket Ok.
- cast to char ptrs and printf'd the results are definitely NOT null.
- szq_connect() returns 0 (success)
- szq_sendmsg() returns 5 (bytes sent)
- and hwserver does NOT receive the message!
B. I tried declaring the socket variable still as a member of a struct
but with the struct in the sendZmqMsg() function itself:
PPMDB_ZMQ_INFO zi;
LPPPMDB_ZMQ_INFO pzi = &zi;
setting the local struct context from the passed in context:
sendZmqMsg() On entry lpzmqInfo->vpContext=[a»_¦°S<]
pzi->vpContext = lpzmqInfo->vpContext;
then setting the local zi.vpSocket from the local zi.vpContext:
pzi->vpSocket = zmq_socket (&pzi->vpContext, ZMQ_REQ);
Well that doesn't work any better:
- zmq_socket() returns NULL
- zmq_connect() returns -1 (error)
- zmq_sendmsg() returns -1 (error)
- and hwserver does NOT receive the message!
C. Finally I just defined a local vpSocket variable in the function:
void * vpSocket;
vpSocket = zmq_socket (lpzmqInfo->vpContext, ZMQ_REQ);
nRet = zmq_connect (vpSocket, "tcp://localhost:5555");
nRet = zmq_sendmsg (vpSocket, &lpzmqInfo->mtMsg, 0);
Referencing a local vpSocket variable works. Which it should.
Why the message should get sent when the socket is a simple local variable and not when it's a member of a struct baffles me.
Hopefully someone will be able to point out the egregious error
i'm making.
The 0MQ version i'm using is 3.0.1 on Windows XP/Windows Server 2003
The application is a single threaded (/ML) client.
There are many transient clients and only one permanently online server.
Clients wake up, send a single message to the server, and terminate.
Thanks to anyone who can provide insight on this.