Hello,

I have a particular use case in which I am implementing a non-blocking server() 
that sends data(PUSH socket)  to  client that is in using PULL socket. 
Details :

Server is implemented to use PUSH socket in c using zmq.h(native zeromq). 
SendHWN is set 2 at server side. Server sends 15 messages in non blocking send 
calls.

#######################################
    void *ctx = zmq_ctx_new();
    void *push = zmq_socket(ctx, ZMQ_PUSH);
    int streaming_hwm = 2;
    rc = zmq_setsockopt(push, ZMQ_SNDHWM, &streaming_hwm, 
sizeof(streaming_hwm));
    int linger = 1;
    rc = zmq_setsockopt(push, ZMQ_LINGER, &linger, sizeof(linger));
    rc = zmq_bind(push, "tcp://*:5555");
    sleep(2);
    assert(rc == 0);
    int i = 0;
    for(i =0 ; i < 15 ; i ++){
        char message[] = "This is message";
        zmq_send(push, message, 15, 1);
        printf("data send\n");
        sleep(1);
    }
    zmq_close(push);
    zmq_term(push);
#######################################



Client is implemented using Java and use PULL socket. RcvHWM is set 2 at client 
side.Client recv message in loop and sleeps for 5 second on every recv().
########################################
ZMQ.Context context = ZMQ.context(1);
        //  Socket to send messages on
        ZMQ.Socket receiver = context.socket(ZMQ.PULL);
        receiver.setRcvHWM(2);
        receiver.connect("tcp://10.0.10.61:5555");
        while(true) {
            byte[] b = receiver.recv();
            System.out.println("Data received");
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
#########################################

By using I am expecting to receive around 5-6 messages but got all the 15 
messages at client side. Please suggest if I am doing something wrong. Please 
help and tell what I am doing wrong.


- Best regards
Harsh Badaya
Skype-id : harsh.badaya

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to