aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-11 07:20:34 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-11 07:20:34 -0700
commite5fed94589cff4614b248cb3408397febc0b1be7 (patch)
treedb3e128ee3489c5d654d58d513031c8aaee7c6f7 /src/main
parent65cb239b78d3e75db565309b0196378e29a439d4 (diff)
downloadtrackermap-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.java4
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);
}