import
java.net.*;
import
java.io.*;
public class
localport
{
public static void main ( String [] args)
{
for (String host:args)
{
try
{
Socket theSocket = new Socket(host, 80);
System.out.println("\nConnected to
"+theSocket.getInetAddress()+"\n on port "+theSocket.getPort()+"\n
from port "+theSocket.getLocalPort()+"\n of
"+theSocket.getLocalAddress());
}
catch(UnknownHostException
ex)
{
System.out.println("I
can't find "+host);
}
catch(SocketException
ex)
{
System.out.println("Could
not connect to "+host);
}
catch(IOException
ex)
{
System.out.println(ex);
}
}
}
}