Commit 7cdabe0e authored by 肖健鑫's avatar 肖健鑫
Browse files

1

parent 40daf47f
import java.net.*;
import java.io.*;
public class Client {
public static void main(String[] args) throws IOException {
String host = "localhost";
int port = 12345;
Socket socket = new Socket(host, port);
System.out.println("Connected to server");
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
String userInput;
while ((userInput = stdIn.readLine()) != null) {
out.println(userInput);
System.out.println("Echo: " + in.readLine());
}
out.close();
in.close();
stdIn.close();
socket.close();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment