hi! first of all tell me if you doesn't understand something of my post.
I'm programming a Java chat with a server and several clients (all of them in separate consoles). Everething is alright when I run the server, then a client, the other client...
My problem is that I have to control the "ctrl + c" signal (in the client). In the source code I've implemented this function:
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable(){
public void run (){
try {
System.out.println("Ctrl + c pressed");
Client.disconnect(s, c);
finalize();
} catch (Throwable ex) {
Logger.getLogger(Client.class.getName()).log(Level .SEVERE, null, ex);
}
}
}));
My program lets me pressed ctrl + c but it doesn't enter in this funcion because, this "Ctrl + c pressed" is never printed. That is why my server doesn't remove the client of the list...
Does anyone know why that happend??
Best.