-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtalkclient.java
More file actions
34 lines (32 loc) · 792 Bytes
/
Copy pathtalkclient.java
File metadata and controls
34 lines (32 loc) · 792 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
25
26
27
28
29
30
31
32
33
34
import java.io.*;
import java.net.*;
public class talkclient
{
public static void main(String args[])
{
try
{
Socket socket = new Socket("127.0.0.1",4700);
BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
PrintWriter os = new PrintWriter(socket.getOutputStream());
BufferedReader is = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
String readline;
readline = sin.readLine();
while (!readline.equals("bye"))
{
os.println(readline);
os.flush();
System.out.println("Client:" + readline);
System.out.println("Server:" + is.readLine());
readline = sin.readLine();
}
os.close();
is.close();
socket.close();
}catch(Exception e)
{
System.out.println("Error" + e);
}
}
}