From f82c1969ed2bd5987421b8af88a9106ca101dc4d Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@DESKTOP-2S09UKA>
Date: Wed, 17 Jul 2019 12:33:43 -0700
Subject: [PATCH] Provide more helpful information to user if exception occurs
 due to running twice at one time

---
 examples/src/TcpExamples/TcpExample4Client.java        | 3 +++
 examples/src/TcpExamples/TcpExample4HandlerThread.java | 3 +++
 examples/src/TcpExamples/TcpExample4ThreadServer.java  | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/examples/src/TcpExamples/TcpExample4Client.java b/examples/src/TcpExamples/TcpExample4Client.java
index 29b996c842..9b734a05c0 100644
--- a/examples/src/TcpExamples/TcpExample4Client.java
+++ b/examples/src/TcpExamples/TcpExample4Client.java
@@ -56,6 +56,9 @@ public class TcpExample4Client
         {
             System.out.println("Problem with TcpExample4Client, see exception trace:");
             System.out.println(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!");
         }
     }
 }
\ No newline at end of file
diff --git a/examples/src/TcpExamples/TcpExample4HandlerThread.java b/examples/src/TcpExamples/TcpExample4HandlerThread.java
index 8b51079dbf..b8c93afd11 100644
--- a/examples/src/TcpExamples/TcpExample4HandlerThread.java
+++ b/examples/src/TcpExamples/TcpExample4HandlerThread.java
@@ -58,6 +58,9 @@ public class TcpExample4HandlerThread extends Thread
         {
             System.out.println("Problem with TcpExample4HandlerThread, see exception trace:");
             System.out.println(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 8d2c90eae2..bb47074f78 100644
--- a/examples/src/TcpExamples/TcpExample4ThreadServer.java
+++ b/examples/src/TcpExamples/TcpExample4ThreadServer.java
@@ -36,6 +36,9 @@ public class TcpExample4ThreadServer {
         {
             System.out.println("Problem with TcpExample4ThreadServer, see exception trace:");
             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!");
         }
 		System.out.println("=============================================================");
     }
-- 
GitLab