[zeromq-dev] help

daiweixing daiwx at tongtech.com
Thu Apr 12 11:46:01 CEST 2012


I am new to ZeroMQ, I have following codes:

Dealer is following: 

public class rrbroker {

    public static void main (String[] args) {

        //  Prepare our context and sockets

        Context context = ZMQ.context(1);

 

        Socket backend  = context.socket(ZMQ.DEALER);

        backend.bind("tcp://*:5560");

 

        System.out.println("launch and connect broker.");

 

 

        boolean more = false;

        byte[] message;

 

        //  Switch messages between sockets

        while (!Thread.currentThread().isInterrupted()) {            

            //  poll and memorize multipart detection

 

            {

                while (true) {

                    // receive message

                    backend.send(message, more ? ZMQ.SNDMORE : 0);

                    if(!more){

                        break;

                    }

                }

            }

        }

        //  We never get here but clean up anyhow

        backend.close();

        context.term();

    }

}

 

Client is following:

public class rrclient {

    public static void main(String[] args) throws InterruptedException {

       Context context = ZMQ.context(1);

 

       // Socket to talk to server

       Socket requester = context.socket(ZMQ.REP);

       requester.bind("tcp://*:5560");

//     requester.connect("tcp://localhost:5560");

 

       System.out.println("launch and connect client.");

 

       for (int request_nbr = 0; request_nbr < 1000; request_nbr++) {

           System.out.println("ssssssssssss");

           byte[] reply = requester.recv(0);

       }

 

       // We never get here but clean up anyhow

       requester.close();

       context.term();

    }

 

Above can not work, what’s the matter? Who can help me?

 

Thanks a lot!

 

daiweixing

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120412/a1fc78da/attachment.htm>


More information about the zeromq-dev mailing list