Guest User

Untitled

a guest
Oct 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import org.zeromq.ZMQ;
  2.  
  3. public class Hwserver {
  4.  
  5. public static void main(String[] args) throws Exception {
  6. ZMQ.Context context = ZMQ.context(1);
  7.  
  8. // Socket to talk to clients
  9. ZMQ.Socket responder = context.socket(ZMQ.REP);
  10. responder.bind("tcp://*:5555");
  11.  
  12. while (!Thread.currentThread().isInterrupted()) {
  13. // Wait for next request from the client
  14. byte[] request = responder.recv(0);
  15. System.out.println("Received " + new String (request));
  16.  
  17. // Do some 'work'
  18. Thread.sleep(1000);
  19.  
  20. // Send reply back to client
  21. String reply = "World";
  22. responder.send(reply.getBytes(), 0);
  23. }
  24. responder.close();
  25. context.term();
  26. }
  27. }
Add Comment
Please, Sign In to add comment