Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

EXPERIMENT # 1

AIM:

import java.net.*;

import java.io.*;

class ki

public static void main (String args[])

try

Socket s = new Socket( “nss.” , 25 );

System.out.println( “IP address of remote host” +s.getInetAddress() );

System.out.println(“Port number of remote host” +s.getPort() );

System.out.println(“Port number of local machine” +s.getLocalPort() );

System.out.println(“IP address of local machine” +s.getLocalAddress() );

catch(UnknownHostException ex)

System.err.println(“Unknown Host Exception”);

catch(IOException ex)

System.out.println(“I/O Exception”);

}
catch(SocketException ex)

System.err.println(“Socket Exception);

You might also like