-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatClient.java
More file actions
30 lines (26 loc) · 821 Bytes
/
ChatClient.java
File metadata and controls
30 lines (26 loc) · 821 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
import java.io.*;
import java.net.*;
class ChatClient
{
public static void main(String[] args) throws Exception
{
Socket s = new Socket("localhost", 9999);
BufferedReader sbr = new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(s.getOutputStream());
while(true)
{
System.out.print("Client : ");
String str = br.readLine();
pw.println(str);
pw.flush();
System.out.println();
String ans = sbr.readLine();
System.out.println("Server : " + ans);
System.out.println();
if(!str.toUpperCase().equals("BYE"));
break;
}
s.close();
}
}