diff --git a/CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt b/CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt index 60b9a24afc2c252f4aff7aa66917480d44cd0752..69d5f2bd75d9a5cd5b9323abac71056f6f016c77 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 f469850a93269df41cc54da816c3511eb99dd7c8..3a4ecc63c778154eb78bdb98e84e5d743f1eea2c 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 bab60ab55a88be3b061392bc821863a49a642a80..59869ba800cefec886865cce33cebaf1f196f53f 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 d1da0e1d6be36bdfdc540923f0e5719e11549835..1ed761bf53c8fbfe9c8b88158921e4f0b4f795cc 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 94370eb8f371459a47ca9e4ccd95ae7caea67e18..1b670fe80f2ab8948257202532c5f7cc5d1b4a0c 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... ==================================================