1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = new ServerSocket(7000);
Socket clientSocket = serverSocket.accept();
BufferedReader br = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
PrintWriter pw = new PrintWriter(clientSocket.getOutputStream(), true);
String request, response;
while ((request = br.readLine()) != null) {
if ("Done".equals(request)) {
break;
}
response = request;
pw.println(response);
}
}
|