()
| 107 | private volatile boolean run = true; |
| 108 | |
| 109 | @Override |
| 110 | public void run() { |
| 111 | try (MulticastSocket s = new MulticastSocket(PORT)) { |
| 112 | s.setOption(StandardSocketOptions.IP_MULTICAST_LOOP, Boolean.valueOf(true)); |
| 113 | s.joinGroup(new InetSocketAddress(INET_ADDRESS, 0), null); |
| 114 | DatagramPacket p = new DatagramPacket(new byte[4], 4); |
| 115 | p.setAddress(INET_ADDRESS); |
| 116 | p.setPort(PORT); |
| 117 | long counter = 0; |
| 118 | String msg; |
| 119 | while (run) { |
| 120 | msg = String.format("%04d", Long.valueOf(counter)); |
| 121 | p.setData(msg.getBytes()); |
| 122 | System.out.println("Tx: " + msg); |
| 123 | s.send(p); |
| 124 | counter++; |
| 125 | Thread.sleep(500); |
| 126 | } |
| 127 | } catch (Exception e) { |
| 128 | e.printStackTrace(); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | public void stop() { |
| 133 | run = false; |
nothing calls this directly
no test coverage detected