import java.io.*;
import java.net.*;
class cli
{
public static void main(String ar[])
{
try
{
Socket s=new Socket("localhost",7212);
DataInputStream in=new DataInputStream(System.in);
PrintStream p=new PrintStream(s.getOutputStream());
String str;
System.out.println("Enter IP Adress");
str=in.readLine();
p.println(str);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
import java.io.*;
import java.net.*;
import java.util.*;
class ser
{
public static void main(String ar[])
{
try
{
ServerSocket ss=new ServerSocket(7212);
Socket s=ss.accept();
DataInputStream din=new DataInputStream(s.getInputStream());
String str,str1="",str2="",str3="",str4="",hex;
int i,j,k,l;
str=din.readLine();
System.out.println(str);
StringTokenizer st=new StringTokenizer(str,".");
if(st.countTokens()==4)
{
while(st.hasMoreTokens())
{
str1=st.nextToken();
str2=st.nextToken();
str3=st.nextToken();
str4=st.nextToken();
}
i=Integer.parseInt(str1);
j=Integer.parseInt(str2);
k=Integer.parseInt(str3);
l=Integer.parseInt(str4);
str1=Integer.toHexString(i);
str2=Integer.toHexString(j);
str3=Integer.toHexString(k);
str4=Integer.toHexString(l);
hex=str1+"."+str2+"."+str3+"."+str4;
System.out.println("Equivalent Hexadecimal IP Address");
System.out.println(hex);
}
else
System.out.println("Invalid IP Addresss");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
import java.net.*;
class cli
{
public static void main(String ar[])
{
try
{
Socket s=new Socket("localhost",7212);
DataInputStream in=new DataInputStream(System.in);
PrintStream p=new PrintStream(s.getOutputStream());
String str;
System.out.println("Enter IP Adress");
str=in.readLine();
p.println(str);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
import java.io.*;
import java.net.*;
import java.util.*;
class ser
{
public static void main(String ar[])
{
try
{
ServerSocket ss=new ServerSocket(7212);
Socket s=ss.accept();
DataInputStream din=new DataInputStream(s.getInputStream());
String str,str1="",str2="",str3="",str4="",hex;
int i,j,k,l;
str=din.readLine();
System.out.println(str);
StringTokenizer st=new StringTokenizer(str,".");
if(st.countTokens()==4)
{
while(st.hasMoreTokens())
{
str1=st.nextToken();
str2=st.nextToken();
str3=st.nextToken();
str4=st.nextToken();
}
i=Integer.parseInt(str1);
j=Integer.parseInt(str2);
k=Integer.parseInt(str3);
l=Integer.parseInt(str4);
str1=Integer.toHexString(i);
str2=Integer.toHexString(j);
str3=Integer.toHexString(k);
str4=Integer.toHexString(l);
hex=str1+"."+str2+"."+str3+"."+str4;
System.out.println("Equivalent Hexadecimal IP Address");
System.out.println(hex);
}
else
System.out.println("Invalid IP Addresss");
}
catch(Exception e)
{
System.out.println(e);
}
}
}