diff --git a/examples/src/TcpExamples/TcpExample1Telnet.java b/examples/src/TcpExamples/TcpExample1Telnet.java index 444cb6a7d9b98b468ebab7ea256ce48bb9a9c9e9..fcb8b9571a188402078ae0ec014dda9dbf8eb491 100644 --- a/examples/src/TcpExamples/TcpExample1Telnet.java +++ b/examples/src/TcpExamples/TcpExample1Telnet.java @@ -58,7 +58,7 @@ public class TcpExample1Telnet // The Socket object represents the connection between // the server and client, including a full duplex connection - try (Socket clientConnection = serverSocket.accept()) // wait here for a client to connect + try (Socket clientConnection = serverSocket.accept()) // listen, wait here for a client to connect { // OK we got something, time to respond! // Use Java io classes to write text (as opposed to diff --git a/examples/src/TcpExamples/TcpExample2ConnectionCounting.java b/examples/src/TcpExamples/TcpExample2ConnectionCounting.java index 99feb6facef622f237e635f097f419a8bbb623a0..0acdd8e44089f02dbd7c540e55b2f1b88e3e19d9 100644 --- a/examples/src/TcpExamples/TcpExample2ConnectionCounting.java +++ b/examples/src/TcpExamples/TcpExample2ConnectionCounting.java @@ -36,6 +36,7 @@ public class TcpExample2ConnectionCounting { try { + // welcome aboard messages System.out.println("TcpExample2ConnectionCounting has started and is waiting for a connection."); System.out.println(" help: https://savage.nps.edu/Savage/developers.html#telnet"); System.out.println(" Windows ipconfig (or Mac ifconfig) indicates current IPv4_Address (for example local wireless IP address)"); @@ -56,8 +57,8 @@ public class TcpExample2ConnectionCounting while(true) { // serverSocket.accept() blocks! then proceeds once a connection is "accept"ed - try (Socket clientConnection = serverSocket.accept()) { - connectionCount++; // got another one! + try (Socket clientConnection = serverSocket.accept()) { // the accept() method blocks here until a client connects + connectionCount++; // got another one! a client has connected OutputStream os = clientConnection.getOutputStream(); PrintStream ps = new PrintStream(os); @@ -109,7 +110,7 @@ public class TcpExample2ConnectionCounting ps.flush(); } } - } + } catch(IOException e) { System.err.println("Problem with " + TcpExample2ConnectionCounting.class.getName() + " networking:"); // describe what is happening