public void stopServer ( ) { Log ( Level . INFO , "Attempting to stop SocketServer" ) ; keepRunning = false ; // Thread will be blocked waiting for input - unblock it by closing the socket underneath it: if ( this . serverSocket != null ) { try { this . serverSocket . close ( ) ; } catch ( IOException e ) { Log ( Level . WARNING , "Something happened when closing SocketServer: " + e ) ; } this . serverSocket = null ; } }
Immediately stop waiting for messages and close the SocketServer .