• Post Reply Bookmark Topic Watch Topic
  • New Topic

.accept() problem

 
Billy Bob
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hopefully this is the right forum, I didn't know whether or not in belonged in sockets or threads, so the mods can move it to the other one if necessary, and sorry for the problems if you do.

So, what we're suppose to be doing is creating a multi-threaded server that allows for, possibly, an infinite amount of clients. The program keeps running till one of the clients sends the "kill" command to the server, which keeps running and accepting clients until there are no more connected. Everything works, EXCEPT the stuff to kill the server. Here's what I got

server.java(which also contains the SocketHandler class):
it begins by making a new ServerSocket, followed by an instance over my server class, and a Socket s. It then goes into a while loop that looks like:


works fine. the SocketHandler class works fine too, it can do everything it's suppose to and detect the kill command. Now from the requiriments I have this is how it says to do this. When kill is called, set done = true, call server.theThread.interrupt() to interrupt accept, and in the exception handler do some stuff. The problem is, when I call server.theThread.interrupt, it's not doing anything. I understand why it needs to be called, but it really makes no sense why it should be called the way it is, and it's also not working. Any suggestions would be appreciated.
 
sujit Mahapatra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try making the instance of ServerSocket you have to null in another thread.
This is required because interrupt() will not interrupt accept().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!