Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COMPUTER SCIENCE. SOCKET PROGRAMMING IN JAVA. For the following 3 sets of codes, make 1 0 improvements ( I mean add 1 0 new things

COMPUTER SCIENCE.
SOCKET PROGRAMMING IN JAVA.
For the following 3 sets of codes, make 10 improvements( I mean add 10 new things in each set). So,30 improvements in total
In each comment, the improvement you made.
Do not use AI
***********************FIND LOCAL IP*********
//Following example shows how to find local IP
//Address & Hostname of the system
//using getLocalAddress() method of InetAddress class.
import java.net.InetAddress;
public class LocalIP {
public static void main(String[] args)
throws Exception {
InetAddress addr = InetAddress.getLocalHost();
System.out.println("Local HostAddress: "+addr.getHostAddress());
String hostname = addr.getHostName();
System.out.println("Local host name: "+hostname +);
}
}
***********************CHANGE HOST NAME****************
//Following example shows how to change the host name to its //specific IP address with the help of InetAddress.getByName()//method of net.InetAddress class.
import java.net.InetAddress;
import java.net.UnknownHostException;
public class GetIP {
public static void main(String[] args){
InetAddress address = null;
try {
address = InetAddress.getByName("www.daystar.ac.ke");
// System.in.println("Enter the DOMAIN NAME");
}
catch (UnknownHostException e){
System.exit(2);
}
System.out.println("The organization IP addresss detected for -"+address.getHostName()+" DOMAIN IS "+ address.getHostAddress());
System.exit(0);
}
}
****************CHANGE HOST NAME:Translate IP TO DNS**********
//Following example shows how to change the host name to its specific
//IP address with the help of InetAddress.getByName() method of net.InetAddress class.
import java.net.InetAddress;
public class TranslateIP {
public static void main(String[] argv) throws Exception {
InetAddress addr = InetAddress.getByName("74.125.67.100");
System.out.println("Host name is: "+addr.getHostName());
System.out.println("Ip address is: "+ addr.getHostAddress());
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. How would you describe your typical day at work?

Answered: 1 week ago

Question

7. What qualities do you see as necessary for your line of work?

Answered: 1 week ago