[zeromq-dev] Router-Dealer Example not working in C on 4.0.4 ZMQ release
Badhrinath Manoharan
badhrim at gmail.com
Wed Jul 23 21:50:37 CEST 2014
Hi Peter,
Thanks a lot for your response. I was able to try the same as what you had
mentioned. I used the raw Zeromq APIs instead of the C binds. Below is my
code and the result that I get when. I still don't see them working. Please
let me know where I am going wrong here.
#include </usr/local/include/zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
int main (void)
{
char buffer[15];
void *context = zmq_ctx_new ();
void *router = zmq_socket (context, ZMQ_ROUTER);
void *dealer = zmq_socket (context, ZMQ_DEALER);
memset(buffer, 0, 15);
zmq_bind(router, "tcp://127.0.0.1:9990");
zmq_connect(dealer, "tcp://127.0.0.1:9990");
printf("Sending Message from Dealer\n");
zmq_send(dealer, "Hello World", 11, 0);
printf("Waiting to receive message from Dealer\n");
zmq_recv(router, buffer, 15, 0);
printf("Received message from Dealer: %s\n", buffer);
zmq_close(dealer);
zmq_close(router);
zmq_ctx_destroy(context);
return 0;
}
bash-3.2$ ./zmq_router_dealer
Sending Message from Dealer
Waiting to receive message from Dealer
Received message from Dealer:
bash-3.2$
Thanks
Badhri
On Wed, Jul 23, 2014 at 11:19 AM, Pieter Hintjens <ph at imatix.com> wrote:
> There are no known issues, so it's presumably something in your
> example. The best way to debug such uncertainties is to write a single
> program that does all the work in one thread, e.g.
>
> #include <czmq.h>
>
> int main (void)
> {
> zsock_t *router = zsock_new_router ("tcp://127.0.0.1:9990");
> zsock_t *dealer = zsock_new_dealer ("tcp://127.0.0.1:9990");
>
> zstr_send (dealer, "Hello World");
> zmsg_t *msg = zmsg_recv (router);
> zmsg_print (msg);
> zmsg_send (&msg, router);
> msg = zmsg_recv (dealer);
> zmsg_print (msg);
>
> zmsg_destroy (&msg);
> zsock_destroy (&router);
> zsock_destroy (&dealer);
> return 0;
> }
>
> (using CZMQ master with latest API calls)
>
> On Wed, Jul 23, 2014 at 8:04 PM, Badhrinath Manoharan <badhrim at gmail.com>
> wrote:
> > Hi Zero MQ Team,
> >
> > Zero MQ was introduced to me by one of my friends and was trying to get
> some
> > hands on to it. I have been using C for my development. I have been
> trying
> > to execute the examples provided by zeromq.
> >
> > Was able to get the REQ - REP, PUB - SUB and PUSH - PULL sockets working.
> > However I was not able to get the
> > REQ - ROUTER - DEALER - REP socket working. I just copy pasted the
> examples
> > provided online
> >
> > rrclient: Request-reply client in C
> > rrworker: Request-reply worker in C
> > rrbroker: Request-reply broker in C
> >
> > I could see the REQ - ROUTER working. However a simple DEALER - REP
> socket
> > does not seem to be working. I don't see the messages received by the REP
> > socket. Are there any known issues regarding the ROUTER - DEALER socket.
> > Could someone help me here?
> >
> > Thanks
> > Badhri
> >
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140723/ef74823c/attachment.htm>
More information about the zeromq-dev
mailing list