Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.zeromq.ZMQ;
- public class Hwserver {
- public static void main(String[] args) throws Exception {
- ZMQ.Context context = ZMQ.context(1);
- // Socket to talk to clients
- ZMQ.Socket responder = context.socket(ZMQ.REP);
- responder.bind("tcp://*:5555");
- while (!Thread.currentThread().isInterrupted()) {
- // Wait for next request from the client
- byte[] request = responder.recv(0);
- System.out.println("Received " + new String (request));
- // Do some 'work'
- Thread.sleep(1000);
- // Send reply back to client
- String reply = "World";
- responder.send(reply.getBytes(), 0);
- }
- responder.close();
- context.term();
- }
- }
Add Comment
Please, Sign In to add comment