java.lang.Object
test.MyServer
-
Constructor Summary
ConstructorsConstructorDescriptionMyServer(int port, ClientHandler ch) The MyServer function is a constructor for the MyServer class. -
Method Summary
-
Constructor Details
-
MyServer
The MyServer function is a constructor for the MyServer class. It initializes the port number, client handler and stop boolean to be used by the server. It also creates a thread pool of cached threads that will be used by the server to handle clients.- Parameters:
port- int -Set the port number that the server will listen toch- ClientHandler -Handle the client's request
-
-
Method Details
-
start
public void start()The start function starts the server in a new Thread. -
close
The close function is used to close the thread pool. It sets the stop variable to true, and then shuts down the thread pool and end the server by exiting the loop in the startServer function. If there are any threads that are still running, it will wait for them to finish before shutting down.- Throws:
InterruptedException
-