-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
44 lines (36 loc) · 1.07 KB
/
Copy pathClient.java
File metadata and controls
44 lines (36 loc) · 1.07 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
import java.util.*;
import java.io.*;
import java.net.*;
public class Client
{
public static void main(String[] args) throws Exception
{
Socket clientsocket=new Socket("localhost",2000);
System.out.println("\nClient Here");
System.out.println("____________");
//keyboard input
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
//input stream
BufferedReader br=new BufferedReader(new InputStreamReader(clientsocket.getInputStream()));
//output stream
PrintStream ps=new PrintStream(clientsocket.getOutputStream());
//Give inputs and recieve reversed outputs
String msg;
System.out.println();
do
{
System.out.println("Provide Input:");
msg=input.readLine(); //got input
ps.println(msg); //send input
System.out.println("\nWaiting for Server Response...");
msg=br.readLine();
System.out.println("Reversed output:"+msg+"\n");
}while(!msg.equals("dne"));
System.out.println("\nClosing Client Socket");
clientsocket.close();
//closing streams
input.close();
br.close();
ps.close();
}
}