Skip to content

Instantly share code, notes, and snippets.

@moea
Created April 3, 2013 13:21
Show Gist options
  • Save moea/5301158 to your computer and use it in GitHub Desktop.
Save moea/5301158 to your computer and use it in GitHub Desktop.
import android.os.Handler;
import org.jeromq.ZMQ;
public class ZeroMQServer implements Runnable {
private final Handler uiThreadHandler;
public ZeroMQServer(Handler uiThreadHandler) {
this.uiThreadHandler = uiThreadHandler;
}
@Override
public void run() {
ZMQ.Context context = ZMQ.context(1);
ZMQ.Socket socket = context.socket(ZMQ.REP);
socket.bind("tcp://127.0.0.1:5555");
while(!Thread.currentThread().isInterrupted()) {
byte[] msg = socket.recv(0);
uiThreadHandler.sendMessage(
Util.bundledMessage(uiThreadHandler, new String(msg)));
socket.send(Util.reverseInPlace(msg), 0);
}
socket.close();
context.term();
}
}
@ab5y
Copy link

ab5y commented Aug 25, 2020

I know this is quite dated but any idea what the Util class would be called now? Android seems to have no documentation on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment