Skip to content
Snippets Groups Projects
Commit 745ae316 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

demonstrate NetBeans javadoc Analyzer

parent da692916
No related branches found
No related tags found
No related merge requests found
package MV3500Cohort2024JulySeptember.homework2.Timberlake;
import java.net.ServerSocket;
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
*
* @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
*/
public class Server_HW2 {
public static void main(String[] args) {
ServerSocket serverSocket = null;
try {
// Create a socket to listen on port 9876
serverSocket = new ServerSocket(9876);
System.out.println("Server has started, waiting for client...");
while (true) {
// Accept client connection
Socket clientSocket = serverSocket.accept();
System.out.println("Client connected");
// Create GameHandler to handle client
GameHandler gameHandler = new GameHandler(clientSocket);
// Create new thread to handle the game
Thread thread = new Thread(gameHandler);
thread.start();
}
} catch (Exception e) {
e.printStackTrace(); // Print any exceptions that occur
} finally {
try {
if (serverSocket != null && !serverSocket.isClosed()) {
serverSocket.close(); // Close the server socket to release resources
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
package MV3500Cohort2024JulySeptember.homework2.Timberlake;
import java.io.IOException;
import java.net.ServerSocket;
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
*
* @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
*/
public class Server_HW2 {
/** The main method launches the program from the command line, no parameters needed.
* @param args command-line arguments, none needed */
public static void main(String[] args) {
ServerSocket serverSocket = null;
try {
// Create a socket to listen on port 9876
serverSocket = new ServerSocket(9876);
System.out.println("Server has started, waiting for client...");
while (true) {
// Accept client connection
Socket clientSocket = serverSocket.accept();
System.out.println("Client connected");
// Create GameHandler to handle client
GameHandler gameHandler = new GameHandler(clientSocket);
// Create new thread to handle the game
Thread thread = new Thread(gameHandler);
thread.start();
}
} catch (IOException e) {
e.printStackTrace(); // Print any exceptions that occur
} finally {
try {
if (serverSocket != null && !serverSocket.isClosed()) {
serverSocket.close(); // Close the server socket to release resources
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
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