-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.java
More file actions
40 lines (38 loc) · 1.25 KB
/
Copy pathclient.java
File metadata and controls
40 lines (38 loc) · 1.25 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
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.io.*;
import java.net.*;
public class client {
public static void main (String args[])
{
try
{
InetAddress ip=InetAddress.getLocalHost();
Socket s= new Socket(ip,4021);
BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedReader kb= new BufferedReader(new InputStreamReader(System.in));
PrintStream ps = new PrintStream(s.getOutputStream());
System.out.println("Write Something:");
String str = kb.readLine();
String str1;
while(!(str.equals("Exit")))
{
ps.println(str);
str1=br.readLine();
System.out.println(str1);
System.out.println("Write Something");
str= kb.readLine();
}
ps.close();
br.close();
kb.close();
s.close();
System.out.println("Client Program ended");
}
catch(IOException e)
{
System.out.println(e);
}
}
}