/** method to disconnect from the server */
 public void disconnect() throws IOException {
   // if stream connection is present then
   if (streamConnection != null) {
     // close all streams
     dataOutputStream.close();
     dataInputStream.close();
     streamConnection.close();
   }
   // nullify all stream objects
   dataOutputStream = null;
   dataInputStream = null;
   streamConnection = null;
   // initiate garbage collector
   System.gc();
   // set the connected flag to false indicating no connection
   connected = false;
 }