From b285c379c291ad6117160b0b27665a9a4b08497e Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@DESKTOP-2S09UKA>
Date: Tue, 6 Aug 2019 14:47:07 -0700
Subject: [PATCH] rename, improve documentation for clarity

---
 .../src/TcpExamples/TcpExample4Client.java     | 13 +++++++------
 ...ver.java => TcpExample4DispatchServer.java} | 18 ++++++++++--------
 .../TcpExamples/TcpExample4HandlerThread.java  |  7 +++++--
 3 files changed, 22 insertions(+), 16 deletions(-)
 rename examples/src/TcpExamples/{TcpExample4ThreadServer.java => TcpExample4DispatchServer.java} (64%)

diff --git a/examples/src/TcpExamples/TcpExample4Client.java b/examples/src/TcpExamples/TcpExample4Client.java
index cb5655aa82..7e404e708c 100644
--- a/examples/src/TcpExamples/TcpExample4Client.java
+++ b/examples/src/TcpExamples/TcpExample4Client.java
@@ -5,11 +5,13 @@ import java.net.*;
 //import java.time.LocalTime; // conversion?
 
 /**
- * This is a slightly different client. It establishes a connection
- * to the server, then checks how long it takes to read the single
+ * This client program establishes a socket connection
+ * to the dispatch server, then checks how long it takes to read the single
  * line it expects.
  * 
- * @author mcgredo
+ * @author Don McGregor
+ * @author Don Brutzman
+ * @author MV3500 class
  */
 public class TcpExample4Client 
 {
@@ -43,9 +45,8 @@ public class TcpExample4Client
 				InputStream       is  = socket.getInputStream();
 				InputStreamReader isr = new InputStreamReader(is);
 				BufferedReader     br = new BufferedReader(isr);
-System.out.println("client point 1...");
-				String serverMessage = br.readLine(); // blocks?
-System.out.println("client point 2...");
+                
+				String serverMessage = br.readLine(); // blocks
 				long   readTime = System.currentTimeMillis();
 				long timeLength = readTime - startTime;
 
diff --git a/examples/src/TcpExamples/TcpExample4ThreadServer.java b/examples/src/TcpExamples/TcpExample4DispatchServer.java
similarity index 64%
rename from examples/src/TcpExamples/TcpExample4ThreadServer.java
rename to examples/src/TcpExamples/TcpExample4DispatchServer.java
index 131b0e397b..2708ac0769 100644
--- a/examples/src/TcpExamples/TcpExample4ThreadServer.java
+++ b/examples/src/TcpExamples/TcpExample4DispatchServer.java
@@ -4,12 +4,14 @@ import java.io.IOException;
 import java.net.*;
 
 /**
- * An example of using threads to handle multiple connections
- * at the same time. 
+ * A server example that creates and dispaches a new thread to handle 
+ * multiple connections one after another, running in parallel. 
  * 
- * @author mcgredo
+ * @author Don McGregor
+ * @author Don Brutzman
+ * @author MV3500 class
  */
-public class TcpExample4ThreadServer {
+public class TcpExample4DispatchServer {
     
     public static void main(String[] args) // execution starts here
     {
@@ -19,22 +21,22 @@ public class TcpExample4ThreadServer {
 			
 			int connectionCount = 0; // state variable
             
-			System.out.println("TcpExample4ThreadServer ready to accept socket connections...");
+			System.out.println("TcpExample4DispatchServer ready to accept socket connections...");
             while(true) // infinite loop
             {
                 Socket clientConnection = serverSocket.accept(); // block until connected
 
 				connectionCount++; // unblocked, got another connection
 				System.out.println("=============================================================");
-            	System.out.println("TcpExample4ThreadServer.handlerThread invocation for connection #" + connectionCount + "...");
+            	System.out.println("TcpExample4DispatchServer.handlerThread invocation for connection #" + connectionCount + "...");
                 TcpExample4HandlerThread handlerThread = new TcpExample4HandlerThread(clientConnection);
                 handlerThread.start(); // invokes the run() method in that object
-				System.out.println("TcpExample4ThreadServer.handlerThread is launched, awaiting another connection...");
+				System.out.println("TcpExample4DispatchServer.handlerThread is launched, awaiting another connection...");
 			}          
         }
         catch(IOException e)
         {
-            System.out.println("Problem with TcpExample4ThreadServer networking:"); // describe what is happening
+            System.out.println("Problem with TcpExample4DispatchServer networking:"); // describe what is happening
             System.out.println("Error: " + e);
             // Provide more helpful information to user if exception occurs due to running twice at one time
             if (e instanceof java.net.BindException)
diff --git a/examples/src/TcpExamples/TcpExample4HandlerThread.java b/examples/src/TcpExamples/TcpExample4HandlerThread.java
index 6b67f7b8a3..15d423e65a 100644
--- a/examples/src/TcpExamples/TcpExample4HandlerThread.java
+++ b/examples/src/TcpExamples/TcpExample4HandlerThread.java
@@ -4,12 +4,15 @@ import java.io.*;
 import java.net.*;
 
 /**
- * Handles all the logic associated with one connection
+ * A program that handles all logic associated with one socket connection
  * by running in a thread of its own. This is the server
  * portion as well, so we artificially invent what happens
- * if the server can't respond to a connection for 10 sec.
+ * if the server can't respond to a connection for several seconds.
+ * Warning: do not run this class!  It is created automatically by TcpExample4DispatchServer.
  * 
  * @author Don McGregor
+ * @author Don Brutzman
+ * @author MV3500 class
  */
 
 public class TcpExample4HandlerThread extends Thread
-- 
GitLab