diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index 2dfd152..b038e1a 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -62,12 +62,16 @@ public class ChatClient extends JFrame implements KeyListener { JOptionPane.showMessageDialog(null, "Verbindung zum Server \"" + address + "\" fehlgeschlagen."); } finally { - try { + if (connectionToServer != null) { + try { connectionToServer.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + } + + catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } // fromServerReader.close(); (warten auf ServerReader) // toServerWriter.close(); (warten auf ServerWriter) }