From e1ba24eb156d21a3c5b8b251ee3ffb3d47a942c9 Mon Sep 17 00:00:00 2001 From: leahhedgcorth <leahhedgcorth@drmi-l7410-031.ern.nps.edu> Date: Wed, 19 Apr 2023 11:29:54 -0700 Subject: [PATCH] Submission of Assignment 1 --- .../homework1/Hedgcorth/Assignment1Client.java | 2 +- .../homework1/Hedgcorth/Assignment1Server.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assignments/src/MV3500Cohort2023MarchJune/homework1/Hedgcorth/Assignment1Client.java b/assignments/src/MV3500Cohort2023MarchJune/homework1/Hedgcorth/Assignment1Client.java index 081181e82a..6747eddc55 100644 --- a/assignments/src/MV3500Cohort2023MarchJune/homework1/Hedgcorth/Assignment1Client.java +++ b/assignments/src/MV3500Cohort2023MarchJune/homework1/Hedgcorth/Assignment1Client.java @@ -71,7 +71,7 @@ public class Assignment1Client System.out.println("=================================================="); System.out.print ("Client loop " + clientLoopCount + ": "); - System.out.println("we are live!"); + System.out.println("we are live for 20...!"); System.out.println("The message the server sent was: '" + serverMessage + "'"); // socket gets closed, either automatically/silently by this code (or possibly by the server) diff --git a/assignments/src/MV3500Cohort2023MarchJune/homework1/Hedgcorth/Assignment1Server.java b/assignments/src/MV3500Cohort2023MarchJune/homework1/Hedgcorth/Assignment1Server.java index 5ed00e5e4a..0a622df913 100644 --- a/assignments/src/MV3500Cohort2023MarchJune/homework1/Hedgcorth/Assignment1Server.java +++ b/assignments/src/MV3500Cohort2023MarchJune/homework1/Hedgcorth/Assignment1Server.java @@ -55,21 +55,21 @@ public class Assignment1Server { PrintStream ps; InetAddress localAddress, remoteAddress; int localPort, remotePort; - int serverLoopCount = 0; + int serverLoopCount = 20; // Server is up and waiting (i.e. "blocked" or paused) // Loop, infinitely, waiting for client connections. // Stop the program somewhere else. - while (serverLoopCount < 20) { + while (serverLoopCount > 0) { // block until connected to a client try ( Socket clientConnectionSocket = serverSocket.accept()) { - serverLoopCount++; // increment at beginning of loop for reliability + serverLoopCount--; // increment at beginning of loop for reliability // Now hook everything up (i.e. set up the streams), Java style: os = clientConnectionSocket.getOutputStream(); ps = new PrintStream(os); - ps.println("This is response " + serverLoopCount + " produced by the server."); // this gets sent back to client! + ps.println("Connection will end in: " + serverLoopCount + "..."); // this gets sent back to client! // Print some information locally about the Socket connection. // This includes the port and IP numbers on both sides (the socket pair). @@ -78,7 +78,7 @@ public class Assignment1Server { localPort = clientConnectionSocket.getLocalPort(); remotePort = clientConnectionSocket.getPort(); - System.out.print("Server loop " + serverLoopCount + ": "); + //System.out.print("Server loop " + serverLoopCount + ": "); // My socket pair connection looks like this, to localhost: // Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54876 )) -- GitLab