-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatClient.java
More file actions
42 lines (27 loc) Β· 1.19 KB
/
Copy pathChatClient.java
File metadata and controls
42 lines (27 loc) Β· 1.19 KB
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
35
36
37
38
39
40
41
42
import java.io.*;
import java.net.*;
class ChatClient
{
public static void main(String A[]) throws Exception
{
System.out.println("Client Application Is Running...");
Socket sobj = new Socket("localhost", 2100);
System.out.println("Connection Is Successful With The Server");
PrintStream pobj = new PrintStream(sobj.getOutputStream()); // Bolnara
BufferedReader bobj1 = new BufferedReader(new InputStreamReader(sobj.getInputStream()));
BufferedReader bobj2 = new BufferedReader(new InputStreamReader(System.in));
System.out.println("-----------------------------------------------");
System.out.println("------------- Ketanbaba Chat Server -----------");
System.out.println("-----------------------------------------------");
String str1 = null, str2 = null;
System.out.println("Enter Message For Server : ");
while(!(str1 = bobj2.readLine()).equals("End"))
{
pobj.println(str1);
str2 = bobj1.readLine();
System.out.println("Server Says : "+str2);
System.out.println("Enter Message For Server : ");
}
sobj.close();
}
}