Skip to content

Instantly share code, notes, and snippets.

@trevorbernard
Created November 22, 2014 22:01
Show Gist options
  • Save trevorbernard/5311e1dcaaa074654a09 to your computer and use it in GitHub Desktop.
Save trevorbernard/5311e1dcaaa074654a09 to your computer and use it in GitHub Desktop.
Experimental ZeroMQ Socket API with Context automagically managed for you
package org.zeromq.zmq;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import org.junit.Test;
import static org.zeromq.zmq.ZMQ.*;
public class PushPullTest {
@Test
public void testSimplePushPull() {
try (final Socket pull = new Socket(ZMQ_PULL);
final Socket push = new Socket(ZMQ_PUSH)) {
pull.bind("tcp://*:7210");
push.connect("tcp://127.0.0.1:7210");
byte[] expected = "hello".getBytes();
push.send(expected);
byte[] actual = pull.receive();
assertTrue(Arrays.equals(expected, actual));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment