try { ObjectInputStream input = new ObjectInputStream(socket .getInputStream()); o = input.readObject(); } catch(Exception ev){ System.out.println(ev); try{ socket.getoutputstream(); catch(exception e){ //now i know the socket is broken? }