1 package org.sim0mq.test;
2
3 import org.sim0mq.Sim0MQException;
4 import org.zeromq.ZContext;
5 import org.zeromq.ZMQ;
6
7
8
9
10
11
12
13
14
15 public class Toc
16 {
17
18
19
20
21 public static void main(final String[] args) throws Sim0MQException
22 {
23 try (ZContext context = new ZContext(1))
24 {
25
26 ZMQ.Socket responder = context.createSocket(ZMQ.REP);
27 responder.bind("tcp://*:5556");
28
29 while (true)
30 {
31
32 byte[] request = responder.recv(0);
33 String rs = Tic.byte2string(request);
34 if (rs.equals("STOP"))
35 {
36 break;
37 }
38 if (!rs.equals("TIC"))
39 {
40 System.err.println("Request was not TIC");
41 }
42
43
44 byte[] reply = Tic.string2byte("TOC");
45 responder.send(reply, 0);
46 }
47 responder.close();
48 context.destroy();
49 }
50 }
51 }