SLIP 1: Write a java program to display IP Address
and Name of client machine.
SERVER:
import
java.io.*;
import
java.net.*;
class
S_Slip1_1
{
public static void main(String a[])
throws Exception
{
ServerSocket ss = new
ServerSocket(1000);
System.out.println("Server
is waiting for client : ");
Socket s =ss.accept();
System.out.println("Client
is connected");
}
}
CLIENT:
import
java.io.*;
import java.net.*;
import java.net.*;
class
C_Slip1_1
{
public static void main(String a[]) throws Exception
{
Socket ss = new Socket("localhost",1000);
System.out.println("IP Address = "+ss.getInetAddress());
System.out.println("Client port = "+ss.getPort());
}
}
{
public static void main(String a[]) throws Exception
{
Socket ss = new Socket("localhost",1000);
System.out.println("IP Address = "+ss.getInetAddress());
System.out.println("Client port = "+ss.getPort());
}
}
No comments:
Post a Comment