Package org.zeromq.ZMQ

Examples of org.zeromq.ZMQ.Context.socket()


    //  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");

    //  Subscribe on everything
    frontend.subscribe("".getBytes());
View Full Code Here


public class syncsub{
  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);
View Full Code Here

    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");

    //  - send a synchronization request
    syncclient.send("".getBytes(), 0);
View Full Code Here

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

    Socket socket = context.socket(ZMQ.REQ);
    socket.connect("tcp://localhost:5000");

    for (int i = 0; i < 10; i++) {
      socket.send("Hello", 0);
      String reply = socket.recvStr(0);
View Full Code Here

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

    Socket socket = context.socket(ZMQ.SUB);
    socket.connect("tcp://localhost:5000");

    socket.subscribe("tech".getBytes());
    socket.subscribe("music".getBytes());
View Full Code Here

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

    Socket socket = context.socket(ZMQ.PUB);
    socket.bind("tcp://localhost:5000");

    String[] topics = { "tech", "music", "design" };
    while (!Thread.currentThread().isInterrupted()) {
      for (int i = 0; i < topics.length; i++) {
View Full Code Here

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

    Socket pub = context.socket(ZMQ.PUB);
    pub.bind("tcp://localhost:5000");

    Socket receive = context.socket(ZMQ.PULL);
    receive.bind("tcp://localhost:5001");
View Full Code Here

    Context context = ZMQ.context(1);

    Socket pub = context.socket(ZMQ.PUB);
    pub.bind("tcp://localhost:5000");

    Socket receive = context.socket(ZMQ.PULL);
    receive.bind("tcp://localhost:5001");

    while (!Thread.currentThread().isInterrupted()) {
      String message = receive.recvStr(0);
      System.out.println("Received: " + message);
View Full Code Here

  }

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

    Socket send = context.socket(ZMQ.PUSH);
    send.connect("tcp://localhost:5001");

    Socket receive = context.socket(ZMQ.SUB);
    receive.connect("tcp://localhost:5000");
    receive.subscribe("".getBytes());
View Full Code Here

    Context context = ZMQ.context(1);

    Socket send = context.socket(ZMQ.PUSH);
    send.connect("tcp://localhost:5001");

    Socket receive = context.socket(ZMQ.SUB);
    receive.connect("tcp://localhost:5000");
    receive.subscribe("".getBytes());

    Poller poller = new Poller(0);
    poller.register(receive, Poller.POLLIN);
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.