-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyClient.java
42 lines (34 loc) · 1.05 KB
/
MyClient.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
package dummy;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.Socket;
public class MyClient {
public MyClient() {
// TODO Auto-generated constructor stub
System.out.println("IN Construstor");
}
static {
System.out.println("IN STAIC");
}
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Socket s=new Socket("localhost",3333);
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
//System.out.println("in client");
str=br.readLine();
//System.out.println("in client");
dout.writeUTF(str);
dout.flush();
str2=din.readUTF();
System.out.println("Server says: "+str2);
}
dout.close();
s.close();
}
}