[zeromq-dev] Need help to implement the ZMQ_Device

Rashmiranjan Behuria rashmiranjanb at fss.co.in
Mon Oct 21 10:17:13 CEST 2013

Dear Team,


We are facing issue while implementing the sample code 4.0.1 downloaded.
Plz advice the way forward.



We are using the sample code "local_thr" shared in 4.0.1 sources, where
we are able to send the packet to Queue from normal TCP client but while
responding back to Queue is success from  zmq_sendmsg() api but its not
reaching to the client. I have attached the code below for reference,
Kindly confirm whether our way of implementation is correct or any
changes require.    



const char *bind_to;

     int message_count;

    size_t message_size;

    void *ctx;

    void *s;

    int rc;

    int i;

    zmq_msg_t msg;

       zmq_msg_t rplymsg;

    void *watch;

    unsigned long elapsed;

    unsigned long throughput;

    double megabits;


       //assert (2, 1);

       printf("Inside function\n");

       if (argc != 4) {

        printf ("usage: local_thr <bind-to> <message-size>

        return 1;


    bind_to = argv [1];


    message_size = atoi (argv [2]);

    message_count = atoi (argv [3]);


    ctx = zmq_init (1);

    if (!ctx) {

        printf ("error in zmq_init: %s\n", zmq_strerror (errno));

        return -1;



       void *context = zmq_ctx_new ();

       void *frontend = zmq_socket (context, ZMQ_STREAM);


       void *backend = zmq_socket (context, ZMQ_STREAM);


       rc = zmq_bind (frontend, "tcp://*:5555");


       printf("RC Value : %d\n",rc);


       int rc1 = zmq_bind (backend, "tcp://*:5556");


       printf("RC1 value : %d\n",rc1);


       rc = zmq_msg_init (&msg);

    if (rc != 0) {

        printf ("error in zmq_msg_init: %s\n", zmq_strerror (errno));

        return -1;


       //int ret = zmq_device (ZMQ_QUEUE, frontend,backend);




              rc = zmq_recvmsg (frontend, &msg, 0); 


              printf("\n\t\t  RECEIVE MESSAGE : %s",&msg); //Receive
Success and printing also


              if (rc < 0) {

                     printf ("error in zmq_recvmsg: %s\n", zmq_strerror

                     return -1;



              int val = zmq_sendmsg(frontend,&msg,0);

              printf("\n\t\t Sending Msg : %s VAL %d",&msg,val);



              /*char http_response [] =

                "HTTP/1.0 200 OK\r\n"

                "Content-Type: text/plain\r\n"


                "Hello, World!";

              zmq_send (frontend, http_response, strlen (http_response),

              printf("\n\t\t Sending Msg : %s",http_response);*/






       rc = zmq_close (frontend);

    if (rc != 0) {

        printf ("error in zmq_close: %s\n", zmq_strerror (errno));

        return -1;


       rc = zmq_close (backend);

    if (rc != 0) {

        printf ("error in zmq_close: %s\n", zmq_strerror (errno));

        return -1;



    rc = zmq_term (context);

    if (rc != 0) {

        printf ("error in zmq_term: %s\n", zmq_strerror (errno));

        return -1;





Thanks & Regards,


POS Team


                                         G 4 1st Cross Street SIPCOT IT
Park, Rajiv Gandhi Salai(OMR) Siruseri Navalur Chennai TN - 603 103

                                                    Tel: +91 44 4741
5600 Ext: 3351 | Fax: +91 44 4741 5601 | Web: www.fss.co.in

                                        Email: rashmiranjanb at fss.co.in
<mailto:rashmiranjanb at fss.co.in>  | Mobile: +91 9566080845

"Positive thinking is not about expecting the best to happen. It's about
accepting that whatever will happen for the best"

==========================================================================================================================================================The information contained in this e-mail message may be privileged and/or confidential and protected from disclosure under applicable law. It is intended only for the individual to whom or entity to which it is addressed as shown at the beginning of the message. If the reader of this message is not the intended recipient, or if the employee or agent responsible for delivering the message is not an employee or agent of the intended recipient, you are hereby notified that any review, dissemination,distribution, use, or copying of this message is strictly prohibited. If you have received this message in error, please notify us immediately by return e-mail and permanently delete this message and your reply to the extent it includes this message. Any views or opinions presented in this message or attachments are those of the author and do not necessarily represent those of the Company. All e-mails and attachments sent and received are subject to monitoring, reading, and archival by the Company.==========================================================================================================================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131021/5ea820ee/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 4989 bytes
Desc: image001.jpg
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131021/5ea820ee/attachment.jpg>

More information about the zeromq-dev mailing list