From e3f86e5af31fbfc918b3feb41eafd580b9963883 Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@nps.edu>
Date: Sat, 25 Aug 2018 12:02:58 -0700
Subject: [PATCH] improved logging format

---
 .../TcpExamples/TcpExample1TerminalLog.txt    |  8 +++++++-
 .../TcpExample2ConnectionCounting.java        | 10 +++++-----
 ...pExample2ConnectionCountingTerminalLog.txt | 20 +++++++++++++++++++
 .../src/TcpExamples/TcpExample3Server.java    |  2 +-
 .../TcpExamples/TcpExample3TerminalLog.txt    | 10 +++++++++-
 5 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt b/CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt
index 60b9a24afc..69d5f2bd75 100644
--- a/CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt
+++ b/CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt
@@ -1,5 +1,10 @@
-Program response:
+Invocation instructions:
+* run/debug TcpExample1Telnet.java
+* console:  telnet localhost 2317
 
+Program responses:
+
+===================================================
 run:
 TcpExample1Telnet has started and is waiting for a connection: telnet localhost 2317
 This server response was written by server TcpExample1
@@ -7,6 +12,7 @@ BUILD SUCCESSFUL (total time: 13 seconds)
 
 Telnet window:
 
+===================================================
 don@it154928 /cygdrive/c/Program Files/NetBeans 8.2
 $  telnet localhost 2317                                                                                                                                                                                            
 Trying ::1...
diff --git a/CourseExamples/src/TcpExamples/TcpExample2ConnectionCounting.java b/CourseExamples/src/TcpExamples/TcpExample2ConnectionCounting.java
index f469850a93..3a4ecc63c7 100644
--- a/CourseExamples/src/TcpExamples/TcpExample2ConnectionCounting.java
+++ b/CourseExamples/src/TcpExamples/TcpExample2ConnectionCounting.java
@@ -10,14 +10,14 @@ import java.net.*;
  * out the socket pair the server sees. Run the program via telnet
  * several times and compare the socket pairs.
  * 
- * telnet localhost 2317
+ * <code>telnet localhost 2317</code>
  * 
  * If you're sophisticated you can contact the instructor's computer
  * while running this program.
  * 
  * <code>telnet ipOfServersLaptop 2317</code>
  * 
- * And have him display the socket pairs he got.
+ * And have that machine display the socket pairs received.
  * @author mcgredo
  */
 public class TcpExample2ConnectionCounting 
@@ -33,7 +33,7 @@ public class TcpExample2ConnectionCounting
             // Notice that it is outside the loop; ServerSocket
             // needs to be made only once.
 			
-			int connectionCount = 0; // state
+			int connectionCount = 0; // state variable
             
             ServerSocket serverSocket = new ServerSocket(2317); // server decides here what port to listen on.
 			// of interest: often client doesn't care what port it uses locally when connecting to that server port.
@@ -49,8 +49,8 @@ public class TcpExample2ConnectionCounting
                 OutputStream os = clientConnection.getOutputStream();
                 PrintStream ps = new PrintStream(os);
 
-				        ps.println("This client response was written by server TcpExample2"); // to remote client
-				System.out.println("This server response was written by server TcpExample2"); // to server console
+				        ps.println("This client response was written by server TcpExample2ConnectionCounting"); // to remote client
+				System.out.println("This server response was written by server TcpExample2ConnectionCounting"); // to server console
 				
 				ps.println("You were connection #" + connectionCount + ", by my count");
                 
diff --git a/CourseExamples/src/TcpExamples/TcpExample2ConnectionCountingTerminalLog.txt b/CourseExamples/src/TcpExamples/TcpExample2ConnectionCountingTerminalLog.txt
index bab60ab55a..59869ba800 100644
--- a/CourseExamples/src/TcpExamples/TcpExample2ConnectionCountingTerminalLog.txt
+++ b/CourseExamples/src/TcpExamples/TcpExample2ConnectionCountingTerminalLog.txt
@@ -1,3 +1,23 @@
+Invocation instructions:
+* run/debug TcpExample2.java
+* console:  telnet localhost 2317
+
+Program responses:
+
+===================================================
+run:
+TcpExample2ConnectionCounting has started and is waiting for a connection: telnet localhost 2317
+This server response was written by server TcpExample2ConnectionCounting
+Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 57630 ))
+got another connection, #1
+This server response was written by server TcpExample2ConnectionCounting
+Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 57631 ))
+got another connection, #2
+This server response was written by server TcpExample2ConnectionCounting
+Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 57633 ))
+got another connection, #3
+
+===================================================
 don@it154928 /cygdrive/c/Program Files/NetBeans 8.2
 $  telnet localhost 2317
 Trying ::1...
diff --git a/CourseExamples/src/TcpExamples/TcpExample3Server.java b/CourseExamples/src/TcpExamples/TcpExample3Server.java
index d1da0e1d6b..1ed761bf53 100644
--- a/CourseExamples/src/TcpExamples/TcpExample3Server.java
+++ b/CourseExamples/src/TcpExamples/TcpExample3Server.java
@@ -53,7 +53,7 @@ public class TcpExample3Server {
 				InetAddress localAddress = clientConnection.getLocalAddress();
 				InetAddress remoteAddress = clientConnection.getInetAddress();
 
-				int localPort = clientConnection.getLocalPort();
+				int  localPort = clientConnection.getLocalPort();
 				int remotePort = clientConnection.getPort();
 
 				// My socket pair connection looks like this, to localhost:
diff --git a/CourseExamples/src/TcpExamples/TcpExample3TerminalLog.txt b/CourseExamples/src/TcpExamples/TcpExample3TerminalLog.txt
index 94370eb8f3..1b670fe80f 100644
--- a/CourseExamples/src/TcpExamples/TcpExample3TerminalLog.txt
+++ b/CourseExamples/src/TcpExamples/TcpExample3TerminalLog.txt
@@ -1,11 +1,19 @@
+Invocation instructions:
+* run/debug TcpExample3Server.java
+* run/debug TcpExample3Client.java
+
+Program responses:
+
+===================================================
 run:
 TcpExample3Server has started...
 Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 49239 ))
 Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 49240 ))
 Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 49241 ))
 [etc.]
+[kill process to exit]
 
-
+===================================================
 run:
 TcpExample3Client creating socket...
 ==================================================
-- 
GitLab