From d6b412f2a7ff3f374744e92bc264b65ac08b9e2a Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@nps.edu>
Date: Wed, 12 Apr 2023 12:01:00 -0700
Subject: [PATCH] explanatory comments

---
 examples/src/TcpExamples/TcpExample1Telnet.java            | 2 +-
 .../src/TcpExamples/TcpExample2ConnectionCounting.java     | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/examples/src/TcpExamples/TcpExample1Telnet.java b/examples/src/TcpExamples/TcpExample1Telnet.java
index 444cb6a7d9..fcb8b9571a 100644
--- a/examples/src/TcpExamples/TcpExample1Telnet.java
+++ b/examples/src/TcpExamples/TcpExample1Telnet.java
@@ -58,7 +58,7 @@ public class TcpExample1Telnet
             
             // The Socket object represents the connection between
             // the server and client, including a full duplex connection
-            try (Socket clientConnection = serverSocket.accept()) // wait here for a client to connect
+            try (Socket clientConnection = serverSocket.accept()) // listen, wait here for a client to connect
             {
                 // OK we got something, time to respond!
                 // Use Java io classes to write text (as opposed to
diff --git a/examples/src/TcpExamples/TcpExample2ConnectionCounting.java b/examples/src/TcpExamples/TcpExample2ConnectionCounting.java
index 99feb6face..0acdd8e440 100644
--- a/examples/src/TcpExamples/TcpExample2ConnectionCounting.java
+++ b/examples/src/TcpExamples/TcpExample2ConnectionCounting.java
@@ -36,6 +36,7 @@ public class TcpExample2ConnectionCounting
     {
         try
         {
+            // welcome aboard messages
             System.out.println("TcpExample2ConnectionCounting has started and is waiting for a connection.");
             System.out.println("  help: https://savage.nps.edu/Savage/developers.html#telnet");
             System.out.println("  Windows ipconfig (or Mac ifconfig) indicates current IPv4_Address (for example local wireless IP address)");
@@ -56,8 +57,8 @@ public class TcpExample2ConnectionCounting
             while(true)
             {
                 // serverSocket.accept() blocks! then proceeds once a connection is "accept"ed
-                try (Socket clientConnection = serverSocket.accept()) {
-                    connectionCount++; // got another one!
+                try (Socket clientConnection = serverSocket.accept()) { // the accept() method blocks here until a client connects
+                    connectionCount++; // got another one! a client has connected
                     
                     OutputStream os = clientConnection.getOutputStream();
                     PrintStream ps = new PrintStream(os);
@@ -109,7 +110,7 @@ public class TcpExample2ConnectionCounting
                     ps.flush();
                 }
             }
-       }
+        }
         catch(IOException e)
         {
             System.err.println("Problem with  " + TcpExample2ConnectionCounting.class.getName() + " networking:"); // describe what is happening
-- 
GitLab