-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.java
More file actions
57 lines (51 loc) · 1.22 KB
/
Copy pathclient.java
File metadata and controls
57 lines (51 loc) · 1.22 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
public class client
{
private static Socket s;
private static BufferedReader br;
private static DataInputStream dis;
private static DataOutputStream dos;
private PrintWriter pw;
public static void main(String[] args)
{
try
{
s=new Socket("localhost",1234);
dis=new DataInputStream(s.getInputStream());
dos=new DataOutputStream(s.getOutputStream());
}
catch(UnknownHostException HO)
{
System.out.println("Server Not Found"+HO);
}
catch(IOException SE)
{
System.out.println("Socket"+"Failed....."+SE);
System.exit(0);
}
while(true)
{
try
{
System.out.println("\nEnter"+"Message for Charu's chat"+"server....");
br=new BufferedReader(new InputStreamReader(System.in));
String getMsg=br.readLine();
dos.writeUTF(getMsg);
String respo=dis.readUTF();
System.out.println(respo);
}
catch(IOException io)
{
System.out.println("" +"Server Failed....."+io);
System.exit(0);
}
}
}
}