From de7daa17b9534135282e1a1029d03c1aec9af89f Mon Sep 17 00:00:00 2001
From: adfis <adfis@DESKTOP-1KB21H8>
Date: Tue, 10 Aug 2021 09:46:04 -0700
Subject: [PATCH] Fisher Homework 2 - Draft

---
 .../homework2/Fisher/FisherClient.java                | 11 +++++++----
 .../homework2/Fisher/FisherServer.java                |  5 ++++-
 examples/src/TcpExamples/TcpExample3Client.java       |  2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherClient.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Fisher/FisherClient.java
index c3d46c8d3c..0c06a6fa5f 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 82c781df98..2da980d6c7 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 e230a0a88a..64113b2e71 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();
-- 
GitLab