From f42dcc7bbe65d6069bfc937aa4ae5d7ec03217e7 Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@DESKTOP-2S09UKA>
Date: Wed, 26 Aug 2020 15:03:31 -0700
Subject: [PATCH] consistent address, port ordering and output on console

---
 .../src/OpenDis7Examples/AllPduReceiver.java  | 10 ++++----
 .../src/OpenDis7Examples/AllPduSender.java    | 24 ++++++++++---------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/examples/src/OpenDis7Examples/AllPduReceiver.java b/examples/src/OpenDis7Examples/AllPduReceiver.java
index f95ee9991e..9bd1189472 100644
--- a/examples/src/OpenDis7Examples/AllPduReceiver.java
+++ b/examples/src/OpenDis7Examples/AllPduReceiver.java
@@ -10,8 +10,8 @@ import java.util.ArrayList;
 
 public class AllPduReceiver
 {
-  public static final int     DEFAULT_MULTICAST_PORT    = AllPduSender.DEFAULT_MULTICAST_PORT;
   public static final String  DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS;
+  public static final int     DEFAULT_MULTICAST_PORT    = AllPduSender.DEFAULT_MULTICAST_PORT;
   public static final boolean USE_FAST_ESPDU = false;
 
   public static void main(String args[])
@@ -24,12 +24,12 @@ public class AllPduReceiver
     try {
       System.out.println("OpenDis7Examples.AllPduReceiver started...");
       if (args.length == 2) {
-        socket = new MulticastSocket(Integer.parseInt(args[0]));
-        address = InetAddress.getByName(args[1]);
+        address = InetAddress.getByName(args[0]);
+        socket  = new MulticastSocket(Integer.parseInt(args[1]));
       }
       else {
-        System.out.println("Usage:   AllPduReceiver <port> <multicast group>");
-        System.out.println("Default: AllPduReceiver " + DEFAULT_MULTICAST_PORT + "   " + DEFAULT_MULTICAST_ADDRESS);
+        System.out.println("Usage:   AllPduReceiver <multicast group> <port>");
+        System.out.println("Default: AllPduReceiver     " + DEFAULT_MULTICAST_ADDRESS + "      " + DEFAULT_MULTICAST_PORT);
         socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
         address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
       }
diff --git a/examples/src/OpenDis7Examples/AllPduSender.java b/examples/src/OpenDis7Examples/AllPduSender.java
index 4a09ff8297..a07816f0e5 100755
--- a/examples/src/OpenDis7Examples/AllPduSender.java
+++ b/examples/src/OpenDis7Examples/AllPduSender.java
@@ -18,7 +18,7 @@ import edu.nps.moves.dis7.enumerations.*;
 public class AllPduSender
 {
     /** Default multicast group address we send on. */
-    public static final String DEFAULT_MULTICAST_ADDRESS = "225.4.5.6"; // "239.1.2.3"; // PduRecorder "225.4.5.6"; //
+    public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; // PduRecorder "225.4.5.6"; //
 	
     /** Default multicast port used, matches Wireshark DIS capture default */
     public static final int    DEFAULT_MULTICAST_PORT    = 3000;
@@ -29,19 +29,19 @@ public class AllPduSender
     /** Number of complete loops to perform */
     private int                SEND_LOOPS_TO_PERFORM = 10;
     
-    private int         port;
-    private InetAddress multicastAddress;
+    private static InetAddress multicastAddress;
+    private static int         port;
 
-    public AllPduSender(int port, String multicast) {
+    public AllPduSender(String newMulticastAddress, int newMulticastPort) {
         this.port = DEFAULT_MULTICAST_PORT;
         try
 		{
-            this.port = port;
-            multicastAddress = InetAddress.getByName(multicast);
+            multicastAddress = InetAddress.getByName(newMulticastAddress);
             if (!multicastAddress.isMulticastAddress())
 			{
-                System.out.println("Not a multicast address: " + multicast);
+                System.out.println("Not a multicast address: " + newMulticastAddress);
             }
+            this.port = newMulticastPort;
         } 
 		catch (UnknownHostException e) {
             System.out.println("Unable to open socket: " + e);
@@ -500,14 +500,16 @@ public class AllPduSender
             
         if (args.length == 2)
         {
-            allPduSender = new AllPduSender(Integer.parseInt(args[0]), args[1]);
+            allPduSender = new AllPduSender(args[0], Integer.parseInt(args[1]));
+            System.out.println("Usage:   AllPduSender <multicast group> <port>");
+            System.out.println("Actual:  AllPduSender  " + multicastAddress.getHostAddress() + "   " + port);
             totalSentPdus = allPduSender.run();
         } 
         else
         {
-            System.out.println("Usage:   AllPduSender <port> <multicast group>");
-            System.out.println("Default: AllPduSender  " + DEFAULT_MULTICAST_PORT + "   " + DEFAULT_MULTICAST_ADDRESS);
-            allPduSender = new AllPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
+            System.out.println("Usage:   AllPduSender <multicast group> <port>");
+            System.out.println("Default: AllPduSender  " + DEFAULT_MULTICAST_ADDRESS + "   " + DEFAULT_MULTICAST_PORT);
+            allPduSender = new AllPduSender(DEFAULT_MULTICAST_ADDRESS, DEFAULT_MULTICAST_PORT);
             totalSentPdus = allPduSender.run();
         }
         System.out.println("OpenDis7Examples.AllPduSender complete, sent " + totalSentPdus + " PDUs total.");
-- 
GitLab