From 5db8214ba3170b4cbca31865d53171ab71b2394a Mon Sep 17 00:00:00 2001
From: terry-norbraten <tnorb@comcast.net>
Date: Thu, 13 Aug 2020 14:57:53 -0700
Subject: [PATCH] use InetSocketAddress

---
 src/edu/nps/moves/dis7/examples/PduSender.java | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/edu/nps/moves/dis7/examples/PduSender.java b/src/edu/nps/moves/dis7/examples/PduSender.java
index dfe38c47dd..e59e18bea0 100644
--- a/src/edu/nps/moves/dis7/examples/PduSender.java
+++ b/src/edu/nps/moves/dis7/examples/PduSender.java
@@ -41,7 +41,7 @@ public class PduSender
       }
     }
     catch (UnknownHostException e) {
-      System.out.println("Unable to open socket: " + e);
+      System.err.println("Unable to open socket: " + e);
     }
   }
 
@@ -289,9 +289,8 @@ public class PduSender
 
       // Send the PDUs we created
       DatagramPacket packet;
-      InetAddress localMulticastAddress = InetAddress.getByName(DisThreadedNetIF.DEFAULT_MCAST_GROUP);
-      MulticastSocket socket = new MulticastSocket(port);
-      InetSocketAddress group = new InetSocketAddress(localMulticastAddress, port);
+      MulticastSocket socket = new MulticastSocket();
+      InetSocketAddress group = new InetSocketAddress(multicastAddress, port);
       socket.joinGroup(group, DisThreadedNetIF.findIpv4Interface());
 
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -303,7 +302,7 @@ public class PduSender
         pdu.marshal(dos);
 
         buffer = baos.toByteArray();
-        packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, port);
+        packet = new DatagramPacket(buffer, buffer.length, group);
         socket.send(packet);
         System.out.println("Sent PDU of type " + pdu.getClass().getSimpleName() + " ("+pdu.getPduType().getValue()+")");
         baos.reset();
-- 
GitLab