diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-11 07:20:34 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-11 07:20:34 -0700 |
commit | e5fed94589cff4614b248cb3408397febc0b1be7 (patch) | |
tree | db3e128ee3489c5d654d58d513031c8aaee7c6f7 /src/main | |
parent | 65cb239b78d3e75db565309b0196378e29a439d4 (diff) | |
download | trackermap-server-e5fed94589cff4614b248cb3408397febc0b1be7.tar.gz trackermap-server-e5fed94589cff4614b248cb3408397febc0b1be7.tar.bz2 trackermap-server-e5fed94589cff4614b248cb3408397febc0b1be7.zip |
Use same socket for sending
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/broadcast/MulticastBroadcastService.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java index 877008eda..134bba797 100644 --- a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java +++ b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java @@ -150,12 +150,10 @@ public class MulticastBroadcastService implements BroadcastService { @Override public void start() throws IOException { service.submit(receiver); - publisherSocket = new DatagramSocket(); } @Override public void stop() { - publisherSocket.close(); service.shutdown(); } @@ -163,6 +161,7 @@ public class MulticastBroadcastService implements BroadcastService { @Override public void run() { try (MulticastSocket socket = new MulticastSocket(port)) { + publisherSocket = socket; socket.joinGroup(group, networkInterface); while (!service.isShutdown()) { DatagramPacket packet = new DatagramPacket(receiverBuffer, receiverBuffer.length); @@ -172,6 +171,7 @@ public class MulticastBroadcastService implements BroadcastService { handleMessage(objectMapper.readValue(data, BroadcastMessage.class)); } socket.leaveGroup(group, networkInterface); + publisherSocket = null; } catch (IOException e) { throw new RuntimeException(e); } |