Skip to content
Snippets Groups Projects
Commit 46da21c1 authored by Timberlake, James (Jack) (LT)'s avatar Timberlake, James (Jack) (LT)
Browse files

HW2 javadoc

parent 80db02fd
No related branches found
No related tags found
No related merge requests found
...@@ -8,8 +8,21 @@ import java.util.Scanner; ...@@ -8,8 +8,21 @@ import java.util.Scanner;
import java.io.PrintWriter; import java.io.PrintWriter;
/** /**
* This client program establishes a socket connection to the {@link GameHandler.java},
* then plays a random number guessing game.
* No fancy footwork here, it is pretty simple and similar to {@link TcpExample3Client}.
*
* see TcpExample4DispatchServer
* see TcpExample4HandlerThread
* *
* @author Jack * @see <a href="../../../src/TcpExamples/TcpExample4TerminalLog.txt" target="blank">TcpExample4TerminalLog.txt</a>
* @see <a href="../../../src/TcpExamples/TcpExample4SequenceDiagram.png" target="blank">TcpExample4SequenceDiagram.png</a>
* @see <a href="../../../src/TcpExamples/TcpExample4SequenceSketch.png" target="blank">TcpExample4SequenceSketch.png</a>
*
* @author Don McGregor
* @author Don Brutzman
* @author MV3500 class
* @author Jack Timberlake
*/ */
......
package MV3500Cohort2024JulySeptember.homework2.Timberlake; package MV3500Cohort2024JulySeptember.homework2.Timberlake;
/** /**
* <p>
* This utility class supports the {@link Server_HW2} program,
* handling all programming logic needed for a new socket connection
* to run 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.
* </p>
* <p>
* Warning: do not run this class! It is created and used automatically by {@link Server_HW2} at run time.
* </p>
*
* see Server_HW2
* see Client_HW2
* *
* @author Jack * @see <a href="../../../src/TcpExamples/TcpExample4TerminalLog.txt" target="blank">TcpExample4TerminalLog.txt</a>
* @see <a href="../../../src/TcpExamples/TcpExample4SequenceDiagram.png" target="blank">TcpExample4SequenceDiagram.png</a>
* @see <a href="../../../src/TcpExamples/TcpExample4SequenceSketch.png" target="blank">TcpExample4SequenceSketch.png</a>
*
* @author Don McGregor
* @author Don Brutzman
* @author MV3500 class
* @author Jack Timberlake
*/ */
import java.io.BufferedReader; import java.io.BufferedReader;
...@@ -14,6 +34,12 @@ import java.util.HashMap; ...@@ -14,6 +34,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class GameHandler implements Runnable { public class GameHandler implements Runnable {
/**
* The thread constructor creates the socket from a ServerSocket, waiting for the client to connect,
* and passes that socket when constructing the thread responsible for handling the connection.
*
* @param socket The socket connection handled by this thread
*/
private Socket clientSocket; private Socket clientSocket;
private int numToGuess; private int numToGuess;
private static final Map<String, String> userCredentials = new HashMap<>(); private static final Map<String, String> userCredentials = new HashMap<>();
......
...@@ -4,8 +4,21 @@ import java.net.ServerSocket; ...@@ -4,8 +4,21 @@ import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
/** /**
* This server program works a bit differently by creating and dispatching a
* new thread to handle multiple incoming socket connections, one after another, all running in parallel.
* This advanced technique is often used in high=performance high=capacity server programs.
*
* @see Client_HW2
* @see GameHandler
* *
* @author Jack * @see <a href="../../../src/TcpExamples/TcpExample4TerminalLog.txt" target="blank">TcpExample4TerminalLog.txt</a>
* @see <a href="../../../src/TcpExamples/TcpExample4SequenceDiagram.png" target="blank">TcpExample4SequenceDiagram.png</a>
* @see <a href="../../../src/TcpExamples/TcpExample4SequenceSketch.png" target="blank">TcpExample4SequenceSketch.png</a>
*
* @author Don McGregor
* @author Don Brutzman
* @author MV3500 class
* @author Jack Timberlake
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment