import java.net.Socket; public class nettest { public static void main( String [] a ) { if( a.length > 0 ) { String host = a[0]; int port = 80; if( a.length > 1 ) { port = Integer.parseInt( a[1] ); } try { Socket si = new Socket( host, port ); System.out.println( "Success connecting to " + host ); } catch( Exception e ) { System.err.println( e.toString() ); e.printStackTrace(); } } else { System.err.println( "please provide host string" ); } } }