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. So , 3 0 improvements in total In

COMPUTER SCIENCE.
SOCKET PROGRAMMING IN JAVA.
For the following 3 sets of codes, make 10 improvements. 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

Recommended Textbook for

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions

Question

how to secure funding building applications

Answered: 1 week ago