-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocket2.java
More file actions
24 lines (22 loc) · 765 Bytes
/
Copy pathSocket2.java
File metadata and controls
24 lines (22 loc) · 765 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
import java.io.*;
import java.net.*;
public class Socket2 {
public static void main(String[] args) throws Exception{
ServerSocket ss = new ServerSocket(6666);
Socket s = ss.accept();
DataInputStream din = new DataInputStream(s.getInputStream());
DataOutputStream dout = new DataOutputStream(s.getOutputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str1 = "", str2 = "";
while(!str1.equals("stop")) {
str1 = din.readUTF();
System.out.println("Client : " + str1);
str2 = br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s.close();
ss.close();
}
}