-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient1.java
More file actions
34 lines (28 loc) · 908 Bytes
/
Copy pathClient1.java
File metadata and controls
34 lines (28 loc) · 908 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
import java.net.*;
import java.io.*;
public class Client1
{
public static void main( String args[]) throws Exception
{
Socket cs = new Socket("localhost",1234);
BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
BufferedReader br = new BufferedReader(new InputStreamReader(cs.getInputStream()));
DataOutputStream dos = new DataOutputStream(cs.getOutputStream());
System.out.println(" Enter text..");
System.out.println(" if client 'quit' type exit");
String s1,s4=null;
while(!(s1=kb.readLine()).equals("exit"))
{
//System.out.println(" data send to server machine");
dos.writeBytes(s1+"\n");
s4 = br.readLine();
//System.out.println(" data receive from server machine");
System.out.println("Server said : "+s4);
System.out.println("Enter text ");
}
System.out.println("Terminated..");
cs.close();
dos.close();
kb.close();
}
}