Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Client with HWM=0.
- import org.zeromq.ZMQ;
- import java.util.concurrent.TimeUnit;
- import static org.zeromq.ZMQ.DEALER;
- import static org.zeromq.ZMQ.SNDMORE;
- public class Client {
- public static void main(String[] args) throws InterruptedException {
- ZMQ.Context ctx = ZMQ.context(1);
- ZMQ.Socket client = ctx.socket(DEALER);
- client.setSndHWM(0); // HWM is setting to 0 in a hope .send() will return false at some point.
- client.connect("tcp://localhost:222");
- long i = 0;
- while (true) {
- // send().
- assert client.send("", SNDMORE); // this line always passes.
- assert client.send(("hello" + i), 0); // this line always passes.
- // recv().
- byte[] world = client.recv();
- assert world != null;
- System.out.println("hello/world complete.");
- i++;
- TimeUnit.SECONDS.sleep(1);
- }
- }
- }
- // ROUTER-server which can be killed sporadically, thereby generating RST to client.
Advertisement
Add Comment
Please, Sign In to add comment