ServerSocket not sending exception
807606Feb 3 2007 — edited Feb 3 2007I have a multithreaded server with clients connected to it. There is a while loop on the client side constantly reading for inputs from the server and vice versa. Now if I close the client it causes a connection reset exception on the server and I can catch it, however if I close the server, there seems to be no exception throw to the client. Any ideas? Here's some sample code on the client..
String response;
try{
socket = new Socket("127.0.0.1", 4587);
socketInput = new BufferedReader(new InputStreamReader(socket.getInputStream()));
socketOutput = new PrintStream(socket.getOutputStream());
System.out.println("Connected to localhost on port 5000...");
String send = "LOGIN"+account+"+"+pwd;
socketOutput.println(send);
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Could not connect to Server, try again", "Server Error", JOptionPane.ERROR_MESSAGE );
}
while (true) { //start while
try{
response = socketInput.readLine();
System.out.println(response);
}catch(Exception e){
System.out.println(e); //No exception thrown when server shuts down
}