diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/Documentation Brennenstuhl.pdf b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/Documentation Brennenstuhl.pdf index 7739c1a0a56776dbd6806e0121381d990a3f17e1..9e33774faa54033de684508c0ac72f781a3a7e8d 100644 Binary files a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/Documentation Brennenstuhl.pdf and b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/Documentation Brennenstuhl.pdf differ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttClient.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttClient.java index 4d39e6900fc4e61727c8a701ba777cecea5bd2a1..1e5ed3ef2c0bc419a968d7da14b2af6e0b17decf 100644 --- a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttClient.java +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttClient.java @@ -11,9 +11,6 @@ import java.net.*; */ public class SchuttClient { - // IPv6 String constant for localhost address, similarly IPv4 127.0.0.1 - - public static void main(String[] args) { // Local vars/fields @@ -58,8 +55,7 @@ public class SchuttClient { System.out.println("=================================================="); System.out.println("Now we're talking!"); System.out.println("The message the server sent was: '" + serverMessage + "'"); - // socket gets closed, either automatically/silently by this code (or possibly by the server) - + //Send equation to the server and wait for the server's reply ps.println(eq); serverMessage = br.readLine(); System.out.println(serverMessage); @@ -74,10 +70,7 @@ public class SchuttClient { if (e instanceof java.net.BindException) { System.err.println("*** Be sure to stop any other running instances of programs using this port!"); } - } finally { - - // program exit: tell somebody about that - - } + } + } } diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttClient.png b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttClient.png new file mode 100644 index 0000000000000000000000000000000000000000..a44906dd1645e4bffb2dfd524df021a19b43534b Binary files /dev/null and b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttClient.png differ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttServer.png b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttServer.png new file mode 100644 index 0000000000000000000000000000000000000000..904bb07758f529b46d649f6772ff811ddcdd9ebd Binary files /dev/null and b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttServer.png differ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttServerDispatcher.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttServerDispatcher.java index 1808be2820dacdde1592fd481bc9a07d1581ee3a..e23e63df7a02a665e0baebd7c043b85a6e64ab61 100644 --- a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttServerDispatcher.java +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttServerDispatcher.java @@ -4,20 +4,8 @@ import java.io.IOException; import java.net.*; /** - * Very slightly more complex than example1, further modifying example2. The - * only thing this does differently is introduce a loop into the response, so - * you don't have to restart the program after one response. Also, it prints out - * the socket pair the server sees. Run the program via telnet several times and - * compare the socket pairs. - * - * telnet (nc) localhost 2317 - * - * If you're sophisticated you can contact the instructor's computer while - * running this program. - * - * telnet (nc) [ipNumberOfServerLaptop] 2317 - * - * and have the instructor display the socket pairs received. + * This is a basic Server Dispatcher that awaits a client to connect and then + * hands the client over to a thread handler to do the required work. * * @author Schutt */ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttThreadHandler.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttThreadHandler.java index 651402c406da2c747f2054fd76f7d5fa8d7c5766..7430c34b559e9bcc4c360980be95b44292554cea 100644 --- a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttThreadHandler.java +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttThreadHandler.java @@ -5,10 +5,8 @@ import java.net.*; /** * A program that handles all logic associated with one socket connection by - * running in a thread of its own. This is the server portion as well, so we - * artificially invent what happens if the server can't respond to a connection - * for several seconds. Warning: do not run this class! It is created - * automatically by TcpExample4DispatchServer. + * running in a thread of its own. This thread will calculate a basic preformed + * equation sent by the client. * * @author Schutt */ @@ -33,9 +31,10 @@ public class SchuttThreadHandler extends Thread { } /** - * Handles one connection. We add an artificial slowness to handling the - * connection with a sleep(). This means the client won't see a server - * connection response for ten seconds (default). + * Handles one connection. We confirm that the connection is made by asking + * the client a basic question and receive a basic equation back from the + * client. The equation is interpreted and solved, with the answer being returned + * to the client. */ // @overriding run() method in Java Thread class is deliberate @Override @@ -52,19 +51,20 @@ public class SchuttThreadHandler extends Thread { ps.println("Please send your equation!"); String clientInput = br.readLine(); + String[] parsedInputs = clientInput.split(""); System.out.println("The Client's equation is: " + clientInput); if(clientInput.contains("+")){ - num1 = (int)clientInput.charAt(0); - num2 = (int)clientInput.charAt(4); + num1 = Integer.parseInt(parsedInputs[0]); + num2 = Integer.parseInt(parsedInputs[4]); System.out.println(num1 + " " + num2); output = num1 + num2; } if(clientInput.contains("*")){ - num1 = (int)clientInput.charAt(0); - num2 = (int)clientInput.charAt(4); + num1 = Integer.parseInt(parsedInputs[0]); + num2 = Integer.parseInt(parsedInputs[4]); output = num1 * num2; } diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttUML.pptx b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttUML.pptx new file mode 100644 index 0000000000000000000000000000000000000000..7a835966fc24eb853392e66555dada16be591a68 Binary files /dev/null and b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttUML.pptx differ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttWireSharkClient.png b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttWireSharkClient.png new file mode 100644 index 0000000000000000000000000000000000000000..fdd533e34a649f6d41c76c2e4f1c1afc489c5604 Binary files /dev/null and b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttWireSharkClient.png differ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttWireSharkServer.png b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttWireSharkServer.png new file mode 100644 index 0000000000000000000000000000000000000000..2479c810b4739fbaab7ca183b5610dfdad56f698 Binary files /dev/null and b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttWireSharkServer.png differ