Examples of recvStr()


Examples of org.zeromq.ZMQ.Socket.recvStr()

        Socket pipe = ZThread.fork(ctx, attached);
        assert (pipe != null);

        pipe.send("ping");
        String pong = pipe.recvStr();

        Assert.assertEquals(pong, "pong");

        // Everything should be cleanly closed now
        ctx.destroy();
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

        Random rand = new Random(System.currentTimeMillis());
        String subscription = String.format("%03d", rand.nextInt(1000));
        subscriber.subscribe(subscription.getBytes());

        while (true) {
            String topic = subscriber.recvStr();
            if (topic == null)
                break;
            String data = subscriber.recvStr();
            assert(topic.equals(subscription));
            System.out.println(data);
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

        while (true) {
            String topic = subscriber.recvStr();
            if (topic == null)
                break;
            String data = subscriber.recvStr();
            assert(topic.equals(subscription));
            System.out.println(data);
        }
        context.destroy();
    }
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

            Socket socket = item.getSocket();

            byte[] identity = socket.recv();
            if (identity != null) {
                //  Request is in second frame of message
                String request = socket.recvStr();
                String subtree = null;
                if (request.equals("ICANHAZ?")) {
                    subtree = socket.recvStr();
                }
                else
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

            if (identity != null) {
                //  Request is in second frame of message
                String request = socket.recvStr();
                String subtree = null;
                if (request.equals("ICANHAZ?")) {
                    subtree = socket.recvStr();
                }
                else
                    System.out.printf("E: bad request, aborting\n");

                if (subtree != null) {
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

        Socket server = context.socket(ZMQ.REP);
        server.bind("tcp://*:5555");

        int cycles = 0;
        while (true) {
            String request = server.recvStr();
            cycles++;

            //  Simulate various problems, after a few cycles
            if (cycles > 3 && rand.nextInt(3) == 0) {
                System.out.println("I: simulating a crash");
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

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

        for (int request_nbr = 0; request_nbr < 10; request_nbr++) {
            requester.send("Hello", 0);
            String reply = requester.recvStr(0);
            System.out.println("Received reply " + request_nbr + " [" + reply + "]");
        }
       
        //  We never get here but clean up anyhow
        requester.close();
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

                //  server is primary; the client must therefore try to connect
                //  to each server in turn:

                if (items[0].isReadable()) {
                    //  We got a reply from the server, must match sequence
                    String reply = client.recvStr();
                    if (Integer.parseInt(reply) == sequence) {
                        System.out.printf ("I: server replied OK (%s)\n", reply);
                        expectReply = false;
                        Thread.sleep(1000)//  One request per second
                    }
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

            client.connect(String.format("ipc://%s-localfe.ipc", self));

            while (true) {
                //  Send request, get reply
                client.send("HELLO", 0);
                String reply = client.recvStr(0);
                if (reply == null)
                    break;              //  Interrupted
                System.out.printf("Client: %s\n", reply);
                try {
                    Thread.sleep(1000);
View Full Code Here

Examples of org.zeromq.ZMQ.Socket.recvStr()

            while (true) {
                //  Tell the broker we're ready for work
                worker.send ("Hi Boss");

                //  Get workload from broker, until finished
                String workload = worker.recvStr ();
                boolean finished = workload.equals ("Fired!");
                if (finished) {
                    System.out.printf ("Completed: %d tasks\n", total);
                    break;
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.