Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ZClient {
- public static void main(String[] args) throws InterruptedException {
- ZMQ.Context ctx = ZMQ.context(1);
- ZMQ.Socket client = ctx.socket(DEALER);
- client.setReceiveTimeOut(1000); // specify 1 sec timeout for .recv().
- client.connect("tcp://" + args[0] + ":222");
- long i = 0;
- while (true) {
- // send().
- assert client.send("", SNDMORE);
- assert client.send(("hello" + i), 0);
- // recv().
- byte[] world = client.recv();
- if (world != null) { // if got null -- no worry, just send again one more time.
- i++;
- System.out.println("hello/world complete.");
- TimeUnit.SECONDS.sleep(1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment