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);
}

}
}
}


OUTPUT:


Leave a Reply

Subscribe to Posts | Subscribe to Comments

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA