-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_log.java
31 lines (25 loc) · 1016 Bytes
/
client_log.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
import java.net.*;
import java.io.*;
public class client_log {
public static void main(String[] args) {
try {
Socket sock = new Socket("127.0.0.1", 6013);
OutputStream out = sock.getOutputStream();
PrintWriter pout = new PrintWriter(out, true);
// Read the input from the user
BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter input: ");
String input = userInput.readLine();
// Send the input to the server
pout.println(input);
// Read the response from the server
InputStream in = sock.getInputStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
String response = bin.readLine();
System.out.println("Server response: " + response);
sock.close();
} catch (IOException ioe) {
System.err.println(ioe);
}
}
}