0% found this document useful (0 votes)
19 views

Lab Assignment-4: Department of Computer Science & Engineering, MRCE, Faridabad

This document contains a lab assignment from the Department of Computer Science & Engineering at MRCE Faridabad for the subject Computer Network Lab. The assignment includes two Java programs, the first to find the local IP address using getLocalHost() and the second to find an IP address by name using getByName(). Both programs print the InetAddress and host name.

Uploaded by

Jatin Singhla
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Lab Assignment-4: Department of Computer Science & Engineering, MRCE, Faridabad

This document contains a lab assignment from the Department of Computer Science & Engineering at MRCE Faridabad for the subject Computer Network Lab. The assignment includes two Java programs, the first to find the local IP address using getLocalHost() and the second to find an IP address by name using getByName(). Both programs print the InetAddress and host name.

Uploaded by

Jatin Singhla
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Department of Computer Science & Engineering, MRCE, Faridabad

LAB ASSIGNMENT-4
Semester: VI

Year:

2016

Subject: COMPUTER NETWORK LAB

Subject Code: IT-305-F

Faculty: Mrs.Yashika

1. Write a program to find IP address by using getLocalHost().


import java.net.*;
import java.io.*;
class GetIP
{
public static void main(String args[]) throws UnknownHostException
{
InetAddress local=InetAddress.getLocalHost();
System.out.println(local);
System.out.println(local.getHostName());
}
}

2. Write a program to find IP address by using GetByName().


import java.net.*;
import java.io.*;

class getname
{
public static void main(String args[]) throws UnknownHostException
{
InetAddress local=InetAddress.getByName("DESKTOPACML4TH");
System.out.println(local);
System.out.println(local.getHostName());
}
}

You might also like