-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc.java
72 lines (54 loc) · 1.65 KB
/
c.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import java.io.*;
import java.util.*;
import java.net.*;
public class c
{
public static void main(String args[]) throws Exception
{
Scanner in=new Scanner(System.in);
String x;
try
{
int i,j;
Socket skt=new Socket("localhost",2598);
DataOutputStream odos=new DataOutputStream(skt.getOutputStream());
DataInputStream odis=new DataInputStream(skt.getInputStream());
BufferedReader obr=new BufferedReader(new InputStreamReader(System.in));
System.out.print("enter domain Name : ");
String user = in.next();
System.out.println();
odos.writeUTF(user);
System.out.println("connecting to server..");
String ans=odis.readUTF();
System.out.println("ipV4 (Local Server) : "+ans);
if(ans.equals("Not found in local server.."))
{
try{
System.out.println("Searching for in Root Server!! ");
Socket skt1=new Socket("localhost",1111);
DataOutputStream odos1=new DataOutputStream(skt1.getOutputStream());
DataInputStream odis1=new DataInputStream(skt1.getInputStream());
skt.close();
BufferedReader obr1=new BufferedReader(new InputStreamReader(System.in));
odos1.writeUTF(user);
String ans1=odis1.readUTF();
System.out.println("ipV4 (Root Server) : "+ans1);
System.out.println(" "+user+" will be available in local server..");
skt1.close();
}
catch(ConnectException ex)
{
System.out.println("error in root server");
}
}
else
{
skt.close();
}
}
catch(ConnectException ex)
{
System.out.println("Server Not Avaliable 404 Error Found");
}
}
}