From 6f101ab9ad38434a0d1109e8cc95d86ccbacc960 Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@nps.edu>
Date: Sun, 30 Apr 2023 08:06:42 -0700
Subject: [PATCH] variable rename for clarity

---
 examples/src/UdpExamples/UnicastUdpSender.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/examples/src/UdpExamples/UnicastUdpSender.java b/examples/src/UdpExamples/UnicastUdpSender.java
index 27ff85fb83..937dda0af6 100644
--- a/examples/src/UdpExamples/UnicastUdpSender.java
+++ b/examples/src/UdpExamples/UnicastUdpSender.java
@@ -45,7 +45,7 @@ public class UnicastUdpSender
         DatagramSocket udpSocket = null;
         DataOutputStream  dos = null;
         int   packetID = 0;     // counter variable to send in packet
-        float    value = -1.0f; // unreachable value is good sentinel to ensure expected changes occur
+        float    countdown = -1.0f; // unreachable value is good sentinel to ensure expected changes occur
         String message = MY_NAME + " says Hello MV3500"; // no really
         String padding = new String();
         
@@ -85,29 +85,29 @@ public class UnicastUdpSender
             for (int index = 1; index <= TOTAL_PACKETS_TO_SEND; index++) // avoid infinite send loops in code, they can be hard to kill!
             {
                 packetID++;                               // increment counter, prefer using explicit value to index
-                value = TOTAL_PACKETS_TO_SEND - packetID; // countdown
+                countdown = TOTAL_PACKETS_TO_SEND - packetID; // countdown from goal total
                 boolean isPacketIdEvenParity = ((packetID % 2) == 0); // % is modulo operator; result 0 is even parity, 1 is odd parity
                 
                 // values of interest follow. order and types of what was sent must match what you are reading!
                 dos.writeInt    (packetID);
-                dos.writeFloat  (value);
+                dos.writeFloat  (countdown);
                 dos.writeUTF    (message); // string value with guaranteed encoding, matches UTF-8 is 8 bit
                 dos.writeBoolean(isPacketIdEvenParity);
                 
-                dos.flush(); // sends DataOutputStream to ByteArrayOutputStream
+                dos.flush(); // sends DataOutputStream to ByteArrayOutputStream, clearing the buffer
                 byteArray = baos.toByteArray();    // OK so go get the flushed result...
                 datagramPacket.setData(byteArray); // and put it in the packet...
                 udpSocket.send(datagramPacket);    // and send it away. boom gone, nonblocking.
 //              System.out.println("udpSocket output port=" + udpSocket.getLocalPort()); // diagnostic tells what port was chosen by system
                 
                 if  (isPacketIdEvenParity)
-                     padding = " ";
-                else padding = "";
+                     padding = " "; // single blank character as a string of length 1
+                else padding = "";  // empty string
             
                 Thread.sleep(100); // Send packets at rate of one per second
                 System.out.println("[" + UnicastUdpSender.class.getName() + "] " + MY_NAME + " " + sourceAddress +
                                    " port=" + UDP_PORT +
-                                   " has sent values (" + packetID + "," + value + ",\"" + message + "\"," + isPacketIdEvenParity +
+                                   " has sent values (" + packetID + "," + countdown + ",\"" + message + "\"," + isPacketIdEvenParity +
                                    ")" + padding + " as packet #" + index + " of " + TOTAL_PACKETS_TO_SEND);
                 baos.reset(); // clear the output stream after sending
             }   // end for loop
-- 
GitLab