private boolean disconnect(){
  if (!done) {
    debug("Comms::SocketThread: 'disconnect' executed, but 'done' is not true.");
  }
  boolean clean=true;
  debug("Shutting down...");
  debug("Waiting for sendqueue to drain");
  put(new Event(EType.KILLSENDER));
  while (sendingThread != null && sendingThread.isAlive()) {
    try {
      sendingThread.join();
    }
 catch (    InterruptedException e) {
    }
  }
  try {
    pclient.shutdownInput();
    pclient.shutdownOutput();
    debug("Streams shutdown.");
  }
 catch (  Exception e) {
    clean=false;
  }
  try {
    oos.close();
    ois.close();
    debug("Streams closed.");
  }
 catch (  Exception e) {
    clean=false;
  }
  try {
    pclient.close();
    debug("Socket closed.");
  }
 catch (  Exception e) {
    clean=false;
  }
  if (isServer) {
    try {
      pserver.close();
      debug("Server stopped");
    }
 catch (    Exception e) {
      clean=false;
    }
  }
  ois=null;
  oos=null;
  pclient=null;
  pserver=null;
  debug(clean ? "Disconnected cleanly" : "No clean disconnect. Apparently was already partially disconnected.");
  return clean;
}

private boolean disconnect ( ) { if ( ! done ) { debug ( "Comms::SocketThread: 'disconnect' executed, but 'done' is not true." ) ; } boolean clean = true ; debug ( "Shutting down..." ) ; debug ( "Waiting for sendqueue to drain" ) ; put ( new Event ( EType . KILLSENDER ) ) ; while ( sendingThread != null && sendingThread . isAlive ( ) ) { try { sendingThread . join ( ) ; } catch ( InterruptedException e ) { } } try { pclient . shutdownInput ( ) ; pclient . shutdownOutput ( ) ; debug ( "Streams shutdown." ) ; } catch ( Exception e ) { clean = false ; } try { oos . close ( ) ; ois . close ( ) ; debug ( "Streams closed." ) ; } catch ( Exception e ) { clean = false ; } try { pclient . close ( ) ; debug ( "Socket closed." ) ; } catch ( Exception e ) { clean = false ; } if ( isServer ) { try { pserver . close ( ) ; debug ( "Server stopped" ) ; } catch ( Exception e ) { clean = false ; } } ois = null ; oos = null ; pclient = null ; pserver = null ; debug ( clean ? "Disconnected cleanly" : "No clean disconnect. Apparently was already partially disconnected." ) ; return clean ; }
this function assumes that done is set to true .
