@Test
public void testEventBindFailed() {
if (ZMQ.version_full() < ZMQ.make_version(3, 2, 2)) // Monitor added in 3.2.2
return;
Context context = ZMQ.context(1);
ZMQ.Event event;
Socket helper = context.socket(ZMQ.REP);
int port = helper.bindToRandomPort("tcp://127.0.0.1");
Socket socket = context.socket(ZMQ.REP);
Socket monitor = context.socket(ZMQ.PAIR);
monitor.setReceiveTimeOut(100);
assertTrue(socket.monitor("inproc://monitor.socket", ZMQ.EVENT_BIND_FAILED));
monitor.connect("inproc://monitor.socket");
try {
socket.bind("tcp://127.0.0.1:" + port);
} catch (ZMQException ex) {}
event = ZMQ.Event.recv(monitor);
assertNotNull("No event was received", event);
assertEquals(ZMQ.EVENT_BIND_FAILED, event.getEvent());
helper.close();
socket.close();
monitor.close();
context.term();
}