private Socket connect(String host,String portString) throws IOException {
  int port=0;
  Socket sock=null;
  boolean DEBUG=Debug.debugging("netmap");
  try {
    port=Integer.parseInt(portString,10);
  }
 catch (  NumberFormatException e) {
    if (DEBUG)     Debug.output("Illegal name " + host + ":"+ portString);
    throw new IOException("Illegal port: " + portString);
  }
  if (DEBUG)   Debug.output("Connecting to server " + host + ":"+ port);
  try {
    sock=new Socket(host,port);
  }
 catch (  IOException e) {
    if (sock != null)     sock.close();
    if (DEBUG) {
      Debug.output("Can't connect to " + host + ":"+ port+ "\n   "+ e);
    }
    throw e;
  }
  return sock;
}

private Socket connect ( String host , String portString ) throws IOException { int port = 0 ; Socket sock = null ; boolean DEBUG = Debug . debugging ( "netmap" ) ; try { port = Integer . parseInt ( portString , 10 ) ; } catch ( NumberFormatException e ) { if ( DEBUG ) Debug . output ( "Illegal name " + host + ":" + portString ) ; throw new IOException ( "Illegal port: " + portString ) ; } if ( DEBUG ) Debug . output ( "Connecting to server " + host + ":" + port ) ; try { sock = new Socket ( host , port ) ; } catch ( IOException e ) { if ( sock != null ) sock . close ( ) ; if ( DEBUG ) { Debug . output ( "Can't connect to " + host + ":" + port + "\n   " + e ) ; } throw e ; } return sock ; }
a general connection method that returns a socket for a host and port .
