Created
March 20, 2011 18:57
-
-
Save sustrik/878554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <zmq.hpp> | |
int main () | |
{ | |
zmq::context_t ctx (1); | |
zmq::socket_t b (ctx, ZMQ_PUSH); | |
b.bind ("tcp://lo:5555"); | |
zmq::socket_t c1 (ctx, ZMQ_PULL); | |
c1.connect ("tcp://localhost:5555"); | |
zmq::message_t msg1; | |
b.send (msg1, ZMQ_SNDMORE); | |
c1.close (); | |
sleep (1); | |
zmq::socket_t c2 (ctx, ZMQ_PULL); | |
c2.connect ("tcp://localhost:5555"); | |
zmq::message_t msg2; | |
b.send (msg2); | |
int64_t more; | |
size_t more_size = sizeof (more); | |
printf ("before recv\n"); | |
zmq::message_t msg3; | |
c2.recv (&msg3); | |
c2.getsockopt (ZMQ_RCVMORE, &more, &more_size); | |
assert (more != 0); | |
printf ("first part recvd\n"); | |
c2.recv (&msg3); | |
c2.getsockopt (ZMQ_RCVMORE, &more, &more_size); | |
assert (more == 0); | |
printf ("second part recvd\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment