-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientsComputer.java
More file actions
47 lines (30 loc) · 982 Bytes
/
Copy pathClientsComputer.java
File metadata and controls
47 lines (30 loc) · 982 Bytes
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
import java.net.*;
import java.io.*;
import java.util.*;
public class ClientsComputer {
public static void main(String[] args){
InetAddress ia = null;
try{
ia = InetAddress.getByName("192.168.200.184");
}catch(Exception ee){}
Socket soc = null;
for(int i =0 ; i <10 ; i++){
try{
soc = new Socket(ia, 12348);
//printout to server
OutputStreamWriter osw = new OutputStreamWriter(soc.getOutputStream());
BufferedWriter bw = new BufferedWriter(osw, 512);
PrintWriter pw = new PrintWriter(bw);
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
pw.println(str);
pw.flush();
//get ping from server
InputStreamReader isr = new InputStreamReader(soc.getInputStream());
BufferedReader br = new BufferedReader(isr, 512);
String data = br.readLine();
System.out.println("He :" + data);
}catch(Exception ee){}
}
}
}