From 5cf8447016ad5b789126ebaaa5ad81be77f64733 Mon Sep 17 00:00:00 2001 From: brutzman <brutzman@DESKTOP-2S09UKA> Date: Wed, 17 Jul 2019 12:43:18 -0700 Subject: [PATCH] consistent diagnostic messages --- examples/src/TcpExamples/TcpExample1Telnet.java | 3 ++- examples/src/TcpExamples/TcpExample2ConnectionCounting.java | 3 ++- examples/src/TcpExamples/TcpExample3Client.java | 4 ++-- examples/src/TcpExamples/TcpExample3Server.java | 2 +- examples/src/TcpExamples/TcpExample4Client.java | 6 +++--- examples/src/TcpExamples/TcpExample4HandlerThread.java | 6 +++--- examples/src/TcpExamples/TcpExample4ThreadServer.java | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/src/TcpExamples/TcpExample1Telnet.java b/examples/src/TcpExamples/TcpExample1Telnet.java index 65afb1959f..074e545611 100644 --- a/examples/src/TcpExamples/TcpExample1Telnet.java +++ b/examples/src/TcpExamples/TcpExample1Telnet.java @@ -64,7 +64,8 @@ public class TcpExample1Telnet } catch(IOException e) { - System.out.println("*** Problem with networking: " + e); + System.out.println("Problem with TcpExample1Telnet 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) System.out.println("*** Be sure to stop any other running instances of programs using this port!"); diff --git a/examples/src/TcpExamples/TcpExample2ConnectionCounting.java b/examples/src/TcpExamples/TcpExample2ConnectionCounting.java index 9ab0e481be..6dfcf88e81 100644 --- a/examples/src/TcpExamples/TcpExample2ConnectionCounting.java +++ b/examples/src/TcpExamples/TcpExample2ConnectionCounting.java @@ -84,7 +84,8 @@ public class TcpExample2ConnectionCounting } catch(IOException e) { - System.out.println("problem with networking: " + e); + System.out.println("Problem with TcpExample2ConnectionCounting 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) System.out.println("*** Be sure to stop any other running instances of programs using this port!"); diff --git a/examples/src/TcpExamples/TcpExample3Client.java b/examples/src/TcpExamples/TcpExample3Client.java index 422c16234c..2824b80b4b 100644 --- a/examples/src/TcpExamples/TcpExample3Client.java +++ b/examples/src/TcpExamples/TcpExample3Client.java @@ -46,8 +46,8 @@ public class TcpExample3Client { } // end while(true) } catch (IOException e) { - System.out.println("Problem with client: "); // describe what is happening - System.out.println(e); + System.out.println("Problem with TcpExample3ServerClient 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) System.out.println("*** Be sure to stop any other running instances of programs using this port!"); diff --git a/examples/src/TcpExamples/TcpExample3Server.java b/examples/src/TcpExamples/TcpExample3Server.java index f6c1523828..92e5db8798 100644 --- a/examples/src/TcpExamples/TcpExample3Server.java +++ b/examples/src/TcpExamples/TcpExample3Server.java @@ -73,7 +73,7 @@ public class TcpExample3Server { } catch (IOException e) { - System.out.println("problem with networking"); + System.out.println("Problem with TcpExample3Server networking: " + e); // Provide more helpful information to user if exception occurs due to running twice at one time if (e instanceof java.net.BindException) System.out.println("*** Be sure to stop any other running instances of programs using this port!"); diff --git a/examples/src/TcpExamples/TcpExample4Client.java b/examples/src/TcpExamples/TcpExample4Client.java index 9b734a05c0..c5049c4537 100644 --- a/examples/src/TcpExamples/TcpExample4Client.java +++ b/examples/src/TcpExamples/TcpExample4Client.java @@ -45,7 +45,7 @@ public class TcpExample4Client long readTime = System.currentTimeMillis(); long timeLength = readTime - startTime; - System.out.println("TcpExample4Client: message received from server=" + serverMessage); + System.out.println("TcpExample4Client: message received from server='" + serverMessage + "'"); System.out.println("TcpExample4Client: time msec required for read=" + timeLength); System.out.println("=================================================="); // To push this further, launch multiple copies of TcpExample4Client simultaneously @@ -54,8 +54,8 @@ public class TcpExample4Client } catch(IOException e) { - System.out.println("Problem with TcpExample4Client, see exception trace:"); - System.out.println(e); + System.out.println("Problem with TcpExample4Client networking: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) System.out.println("*** Be sure to stop any other running instances of programs using this port!"); diff --git a/examples/src/TcpExamples/TcpExample4HandlerThread.java b/examples/src/TcpExamples/TcpExample4HandlerThread.java index b8c93afd11..8518f02a80 100644 --- a/examples/src/TcpExamples/TcpExample4HandlerThread.java +++ b/examples/src/TcpExamples/TcpExample4HandlerThread.java @@ -49,15 +49,15 @@ public class TcpExample4HandlerThread extends Thread System.out.println("TcpExample4HandlerThread pausing for TIMEOUT=" + TIMEOUT + "ms"); // debug Thread.sleep(TIMEOUT); // 10 seconds - ps.println("This was written by the server TcpExample4HandlerThread"); + ps.println("This message was written by the server TcpExample4HandlerThread"); ps.flush(); socket.close(); System.out.println("TcpExample4HandlerThread finished handling a thread, now exit."); } catch(IOException | InterruptedException e) // either a networking or a threading problem { - System.out.println("Problem with TcpExample4HandlerThread, see exception trace:"); - System.out.println(e); + System.out.println("Problem with TcpExample4HandlerThread 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) System.out.println("*** Be sure to stop any other running instances of programs using this port!"); diff --git a/examples/src/TcpExamples/TcpExample4ThreadServer.java b/examples/src/TcpExamples/TcpExample4ThreadServer.java index bb47074f78..131b0e397b 100644 --- a/examples/src/TcpExamples/TcpExample4ThreadServer.java +++ b/examples/src/TcpExamples/TcpExample4ThreadServer.java @@ -34,7 +34,7 @@ public class TcpExample4ThreadServer { } catch(IOException e) { - System.out.println("Problem with TcpExample4ThreadServer, see exception trace:"); + System.out.println("Problem with TcpExample4ThreadServer 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) -- GitLab