Answered step by step
Verified Expert Solution
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 sets of codes, make improvements. So 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 mainString args
throws Exception
InetAddress addr InetAddress.getLocalHost;
System.out.printlnLocal HostAddress: addr.getHostAddress;
String hostname addr.getHostName;
System.out.printlnLocal 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.getByNamemethod of net.InetAddress class.
import java.net.InetAddress;
import java.net.UnknownHostException;
public class GetIP
public static void mainString args
InetAddress address null;
try
address InetAddress.getByNamewwwdaystar.acke;
System.inprintlnEnter the DOMAIN NAME";
catch UnknownHostException e
System.exit;
System.out.printlnThe organization IP addresss detected for address.getHostName DOMAIN IS address.getHostAddress;
System.exit;
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 mainString argv throws Exception
InetAddress addr InetAddress.getByName;
System.out.printlnHost name is: addr.getHostName;
System.out.printlnIp address is: addr.getHostAddress;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started