O'Reilly Forums: Simplechatclient - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Simplechatclient Chapter 15 p518

#1 User is offline   rh55 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 07-February 12

Posted 07 February 2012 - 02:51 PM

I've added a line of code to exit the app when the JFrame is closed. Also, a listener for when the frame gets closed that's supposed to close the socket.

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.addWindowListener(new myListener());

class myListener implements WindowListener {
public void windowClosing(WindowEvent e) {
System.out.println("Window Closing, closing socket");
try{
sock.close();
} catch(IOException ex) {
System.out.println("Error closing socket");
}
}
}

But, I get errors when I close the frame, because I think,
the readerThread is still trying to read from a socket that's closed.

Has anyone modified the code so that the app closes cleanly?

Regards
Richard
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users