package ex2b;
import java.io.IOException;
import java.net.*;
public class Ex2b
{
public static void main(String[] args)
{
try
{
InetAddress addr=InetAddress.getLocalHost();
Socket thesoc=new Socket(addr,139);
System.out.println(“Connected to”+thesoc.getInetAddress()+”on the port”+thesoc.getport()+”from port”+thesoc.getLocalPort()+”of”+thesoc.getLocalAddress());
}
Catch(UnknownHostException e)
{
System.err.println(“I can’t find”+e);
}
Catch(SocketException e)
{
System.err.println(“could not connect”+e);
}
Catch(IOException e)
{
System.err.println(e);
}
}
}
}