Package org.zeromq.ZMQ

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



  public void run() {
    ZContext ctx = new ZContext();
    Socket snapshot = ctx.createSocket(ZMQ.DEALER);
    snapshot.connect("tcp://localhost:5556");

    Socket subscriber = ctx.createSocket(ZMQ.SUB);
        subscriber.connect("tcp://localhost:5557");
        subscriber.subscribe(SUBTREE.getBytes());
View Full Code Here


    ZContext ctx = new ZContext();
    Socket snapshot = ctx.createSocket(ZMQ.DEALER);
    snapshot.connect("tcp://localhost:5556");

    Socket subscriber = ctx.createSocket(ZMQ.SUB);
        subscriber.connect("tcp://localhost:5557");
        subscriber.subscribe(SUBTREE.getBytes());

    Socket publisher = ctx.createSocket(ZMQ.PUSH);
    publisher.connect("tcp://localhost:5558");
View Full Code Here

    Socket subscriber = ctx.createSocket(ZMQ.SUB);
        subscriber.connect("tcp://localhost:5557");
        subscriber.subscribe(SUBTREE.getBytes());

    Socket publisher = ctx.createSocket(ZMQ.PUSH);
    publisher.connect("tcp://localhost:5558");

        Map<String, kvmsg> kvMap = new HashMap<String, kvmsg>();

        // get state snapshot
    snapshot.sendMore("ICANHAZ?");
View Full Code Here

        // Prepare our context and subscriber
        Context context = ZMQ.context(1);
        Socket subscriber = context.socket(ZMQ.SUB);

        subscriber.connect("tcp://localhost:5563");
        subscriber.subscribe("B".getBytes());
        while (!Thread.currentThread ().isInterrupted ()) {
            // Read envelope with address
            String address = subscriber.recvStr ();
            // Read message contents
View Full Code Here

    ZContext ctx = new ZContext();

    Socket output = ctx.createSocket(ZMQ.PAIR);
    output.bind("inproc://zmsg.test");
    Socket input = ctx.createSocket(ZMQ.PAIR);
    input.connect("inproc://zmsg.test");

    // Test send and receive of a single ZMsg
    ZMsg msg = new ZMsg();
    ZFrame frame = new ZFrame("Hello");
    msg.addFirst(frame);
View Full Code Here

    ZContext ctx = new ZContext();

    Socket output = ctx.createSocket(ZMQ.PAIR);
    output.bind("inproc://zmsg.test2");
    Socket input = ctx.createSocket(ZMQ.PAIR);
    input.connect("inproc://zmsg.test2");
   
    ZMsg msg = new ZMsg();
    for (int i = 0;i < 10;i++)
      msg.addString("Frame" + i);
    ZMsg copy = msg.duplicate();
View Full Code Here

  public void testSending() {
    ZContext ctx = new ZContext();
    Socket output = ctx.createSocket(ZMQ.PAIR);
    output.bind("inproc://zframe.test");
    Socket input = ctx.createSocket(ZMQ.PAIR);
    input.connect("inproc://zframe.test");
   
    // Send five different frames, test ZFRAME_MORE
    for (int i=0;i<5;i++) {
      ZFrame f = new ZFrame("Hello".getBytes());
      f.sendAndDestroy(output, ZMQ.SNDMORE);
View Full Code Here

  public void testCopyingAndDuplicating() {
    ZContext ctx = new ZContext();
    Socket output = ctx.createSocket(ZMQ.PAIR);
    output.bind("inproc://zframe.test");
    Socket input = ctx.createSocket(ZMQ.PAIR);
    input.connect("inproc://zframe.test");

    ZFrame f = new ZFrame("Hello".getBytes());
    ZFrame copy = f.duplicate();
    assertTrue(copy.hasSameData(f));
    f.destroy();
View Full Code Here

  public void testReceiving() {
    ZContext ctx = new ZContext();
    Socket output = ctx.createSocket(ZMQ.PAIR);
    output.bind("inproc://zframe.test");
    Socket input = ctx.createSocket(ZMQ.PAIR);
    input.connect("inproc://zframe.test");

    // Send same frame five times
    ZFrame f = new ZFrame("Hello".getBytes());
    for (int i=0;i<5;i++) {
      f.sendAndKeep(output, ZMQ.SNDMORE);
View Full Code Here

  public void testStringFrames() {
    ZContext ctx = new ZContext();
    Socket output = ctx.createSocket(ZMQ.PAIR);
    output.bind("inproc://zframe.test");
    Socket input = ctx.createSocket(ZMQ.PAIR);
    input.connect("inproc://zframe.test");

    ZFrame f1 = new ZFrame("Hello");
    assertEquals(5, f1.getData().length);
    f1.sendAndKeep(output);
   
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.