Skip to content
Snippets Groups Projects
Commit 5cf84470 authored by brutzman's avatar brutzman
Browse files

consistent diagnostic messages

parent f82c1969
No related branches found
No related tags found
No related merge requests found
...@@ -64,7 +64,8 @@ public class TcpExample1Telnet ...@@ -64,7 +64,8 @@ public class TcpExample1Telnet
} }
catch(IOException e) 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 // Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of programs using this port!"); System.out.println("*** Be sure to stop any other running instances of programs using this port!");
......
...@@ -84,7 +84,8 @@ public class TcpExample2ConnectionCounting ...@@ -84,7 +84,8 @@ public class TcpExample2ConnectionCounting
} }
catch(IOException e) 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 // Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of programs using this port!"); System.out.println("*** Be sure to stop any other running instances of programs using this port!");
......
...@@ -46,8 +46,8 @@ public class TcpExample3Client { ...@@ -46,8 +46,8 @@ public class TcpExample3Client {
} // end while(true) } // end while(true)
} }
catch (IOException e) { catch (IOException e) {
System.out.println("Problem with client: "); // describe what is happening System.out.println("Problem with TcpExample3ServerClient networking:"); // describe what is happening
System.out.println(e); System.out.println("Error: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time // Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of programs using this port!"); System.out.println("*** Be sure to stop any other running instances of programs using this port!");
......
...@@ -73,7 +73,7 @@ public class TcpExample3Server { ...@@ -73,7 +73,7 @@ public class TcpExample3Server {
} }
catch (IOException e) 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 // Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of programs using this port!"); System.out.println("*** Be sure to stop any other running instances of programs using this port!");
......
...@@ -45,7 +45,7 @@ public class TcpExample4Client ...@@ -45,7 +45,7 @@ public class TcpExample4Client
long readTime = System.currentTimeMillis(); long readTime = System.currentTimeMillis();
long timeLength = readTime - startTime; 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("TcpExample4Client: time msec required for read=" + timeLength);
System.out.println("=================================================="); System.out.println("==================================================");
// To push this further, launch multiple copies of TcpExample4Client simultaneously // To push this further, launch multiple copies of TcpExample4Client simultaneously
...@@ -54,8 +54,8 @@ public class TcpExample4Client ...@@ -54,8 +54,8 @@ public class TcpExample4Client
} }
catch(IOException e) catch(IOException e)
{ {
System.out.println("Problem with TcpExample4Client, see exception trace:"); System.out.println("Problem with TcpExample4Client networking:networking:"); // describe what is happening
System.out.println(e); System.out.println("Error: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time // Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of programs using this port!"); System.out.println("*** Be sure to stop any other running instances of programs using this port!");
......
...@@ -49,15 +49,15 @@ public class TcpExample4HandlerThread extends Thread ...@@ -49,15 +49,15 @@ public class TcpExample4HandlerThread extends Thread
System.out.println("TcpExample4HandlerThread pausing for TIMEOUT=" + TIMEOUT + "ms"); // debug System.out.println("TcpExample4HandlerThread pausing for TIMEOUT=" + TIMEOUT + "ms"); // debug
Thread.sleep(TIMEOUT); // 10 seconds 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(); ps.flush();
socket.close(); socket.close();
System.out.println("TcpExample4HandlerThread finished handling a thread, now exit."); System.out.println("TcpExample4HandlerThread finished handling a thread, now exit.");
} }
catch(IOException | InterruptedException e) // either a networking or a threading problem catch(IOException | InterruptedException e) // either a networking or a threading problem
{ {
System.out.println("Problem with TcpExample4HandlerThread, see exception trace:"); System.out.println("Problem with TcpExample4HandlerThread networking:"); // describe what is happening
System.out.println(e); System.out.println("Error: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time // Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of programs using this port!"); System.out.println("*** Be sure to stop any other running instances of programs using this port!");
......
...@@ -34,7 +34,7 @@ public class TcpExample4ThreadServer { ...@@ -34,7 +34,7 @@ public class TcpExample4ThreadServer {
} }
catch(IOException e) 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); System.out.println("Error: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time // Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) if (e instanceof java.net.BindException)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment