diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherClient.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherClient.java index c3d46c8d3cc389f0688a61b070d226fbb66394a5..0c06a6fa5f0d3cf966f73b40a87cd9f9c7dd8ae4 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherClient.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherClient.java @@ -22,8 +22,9 @@ import java.net.Socket; public class FisherClient { // IPv6 String constant for localhost address, similarly IPv4 127.0.0.1 - public final static String LOCALHOST = "0:0:0:0:0:0:0:1"; - + public final static String LOCALHOST = "172.20.145.10"; //"0:0:0:0:0:0:0:1"; + // if we sub localhost with someone's IP this + //should work the same /** * Program invocation, execution starts here * @param args command-line arguments @@ -42,14 +43,14 @@ public class FisherClient { try { System.out.println("FisherClient creating socket..."); - while (true) { + while (clientLoopCount <= 10) { // We request an IP to connect to ("localhost") and // port number at that IP (2317). This establishes // a connection to that IP in the form of a Socket // object; the server uses a ServerSocket to wait for // connections. - socket = new Socket(LOCALHOST, 2317); // locohost? + socket = new Socket(LOCALHOST, 2317); os = socket.getOutputStream(); ps = new PrintStream(os); @@ -67,6 +68,8 @@ public class FisherClient { System.out.println("The message the server sent was: '" + serverMessage + "'"); System.out.println("FisherClient responds with: To get to the other side"); + System.out.println("Loop count: " + clientLoopCount); + clientLoopCount++; // socket gets closed, either automatically/silently by this code (or possibly by the server) } // end while(true) diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherServer.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherServer.java index 82c781df98da0bcf2779f861ca4f12fa07d22ad8..2da980d6c7abcba75fe95dd6e0af3a43644a5965 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherServer.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherServer.java @@ -51,11 +51,13 @@ public class FisherServer { InputStream is; InputStreamReader isr; BufferedReader br; + int serverLoopCount = 0; + // Server is up and waiting (i.e. "blocked" or paused) // Loop, infinitely, waiting for client connections. // Stop the program somewhere else. - while (true) { + while (serverLoopCount <= 10) { // block until connected to a client try ( Socket clientConnectionSocket = serverSocket.accept()) { @@ -96,6 +98,7 @@ public class FisherServer { // the try w/ resources the Socket object may stay open for // a while after the client has stopped needing this // connection. try w/ resources explicitly ends the connection. + serverLoopCount++; ps.flush(); // like it or not, you're outta here! } diff --git a/examples/src/TcpExamples/TcpExample3Client.java b/examples/src/TcpExamples/TcpExample3Client.java index e230a0a88a73f186027806f55b5c294fca0adbca..64113b2e71279ff361251f2240ae9898793fffde 100644 --- a/examples/src/TcpExamples/TcpExample3Client.java +++ b/examples/src/TcpExamples/TcpExample3Client.java @@ -47,7 +47,7 @@ public class TcpExample3Client { // a connection to that IP in the form of a Socket // object; the server uses a ServerSocket to wait for // connections. - socket = new Socket(LOCALHOST, 2317); // locohost? + socket = new Socket(LOCALHOST, 2317); // locohost? // Now hook everything up (i.e. set up the streams), Java style: is = socket.getInputStream();