Hi all,
First let me give you an idea of the basic framework of my program. Then I'll let you know what I am having trouble with.
I have a GUI with a button, this button both starts and stops a server. It starts the server by creating the server object, then it creates a
thread to use the server. So, this thread accesses the server.waitForConnection() method that uses the server socket to accept incoming connections. When a new connection is established, another thread is spawned to handle the connection and it goes back to accepting...
(I hope that is clear)
What I want: I want the user to be able to stop the server. Doing so cleans up everything and destroys the server object. The user can then start the server again and a new clean server is created.
What my problem is: How do I clean up all the client connections and threads for every client that connects (there can be any number of these), clean the server sockets and the thread running in the GUI, then clean up the reference to the server socket?
I am not familiar with
Java garbage collection etc. So please any help would be greatly appreciated.
Thank you,
Mark
P.S. please e-mail me at
mpowell@psl.nmsu.edu if something needs clarification.