Package org.zeromq.ZMQ

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


    //  Initialize random number generator
    Random srandom = new Random(System.nanoTime());
    String id = String.format("%04x-%04x", srandom.nextInt(0x10000)+1,srandom.nextInt(0x10000)+1);
    client.setIdentity(id.getBytes());

    client.connect("ipc://frontend.ipc");

    //  Send request, get reply
    client.send("HELLO".getBytes(), 0);
    String reply = new String(client.recv(0));
    System.out.println("Client: " + reply);
View Full Code Here


    //  Initialize random number generator
    Random srandom = new Random(System.nanoTime());
    String id = String.format("%04x-%04x", srandom.nextInt(0x10000)+1,srandom.nextInt(0x10000)+1);
    worker.setIdentity(id.getBytes())//  Makes tracing easier

    worker.connect("ipc://backend.ipc");

    //  Tell backend we're ready for work
    worker.send("READY".getBytes(), 0);

    while(true)
View Full Code Here

  public static void main (String[] args) {
    Context context = ZMQ.context(1);

    //  Socket to talk to server
    Socket requester = context.socket(ZMQ.REQ);
    requester.connect("tcp://localhost:5559");
   
    System.out.println("launch and connect client.");

    for (int request_nbr = 0; request_nbr < 10; request_nbr++) {
      requester.send("Hello".getBytes(), 0);
View Full Code Here

        @Override
        public void run() {
            ZContext ctx = new ZContext();
            Socket worker = ctx.createSocket(ZMQ.DEALER);
            worker.setIdentity("W".getBytes());
            worker.connect("tcp://localhost:5556");
            while (!Thread.currentThread().isInterrupted()) {
                ZMsg msg = ZMsg.recvMsg(worker);
                msg.send(worker);
            }
View Full Code Here

        @Override
        public void run() {
            ZContext ctx = new ZContext();
            Socket client = ctx.createSocket(ZMQ.DEALER);
            client.setIdentity("C".getBytes());
            client.connect("tcp://localhost:5555");
            System.out.println("Setting up test...");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
View Full Code Here

  public static void main (String[] args) {
    Context context = ZMQ.context(1);

    //  Socket to talk to clients
    Socket responder  = context.socket(ZMQ.REP);
    responder.connect("tcp://localhost:5560");
   
    System.out.println("launch and connect server.");

    while (!Thread.currentThread().isInterrupted()) {
      //  Wait for next request from client
View Full Code Here

    //  Prepare our context and sockets
    Context context = ZMQ.context(1);

    //  This is where the weather server sits
    Socket frontend =  context.socket(ZMQ.SUB);
    frontend.connect("tcp://192.168.55.210:5556");

    //  This is our public endpoint for subscribers
    Socket backend  = context.socket(ZMQ.PUB);
    backend.bind("tcp://10.1.1.0:8100");
View Full Code Here

  public static void main (String[] args) {
    Context context = ZMQ.context(1);

    //  First, connect our subscriber socket
    Socket subscriber = context.socket(ZMQ.SUB);
    subscriber.connect("tcp://localhost:5561");
    subscriber.subscribe("".getBytes());

    //  Second, synchronize with publisher
    Socket syncclient = context.socket(ZMQ.REQ);
    syncclient.connect("tcp://localhost:5562");
View Full Code Here

    subscriber.connect("tcp://localhost:5561");
    subscriber.subscribe("".getBytes());

    //  Second, synchronize with publisher
    Socket syncclient = context.socket(ZMQ.REQ);
    syncclient.connect("tcp://localhost:5562");

    //  - send a synchronization request
    syncclient.send("".getBytes(), 0);

    //  - wait for synchronization reply
View Full Code Here

      @Override
      public void run() {
        final String addr = receiverUrl.toString().replaceFirst("zmq:/?/?", "");
        final Socket socket = ZMQ.getSocket(org.zeromq.ZMQ.PUSH);
        try {
          socket.connect(addr);
          socket.send(zmqType, org.zeromq.ZMQ.SNDMORE);
          socket.send(senderUrl.toString(), org.zeromq.ZMQ.SNDMORE);
          socket.send(token, org.zeromq.ZMQ.SNDMORE);
          socket.send(message);
         
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.