Package

Source Code of ChatServer

import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Context;
import org.zeromq.ZMQ.Socket;

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

    while (!Thread.currentThread().isInterrupted()) {
      String message = receive.recvStr(0);
      System.out.println("Received: " + message);
      pub.send(message, 0);
    }

    receive.close();
    pub.close();
    context.term();
  }
}
TOP

Related Classes of ChatServer

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.