-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.java
More file actions
27 lines (23 loc) · 818 Bytes
/
client.java
File metadata and controls
27 lines (23 loc) · 818 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
import java.io.*;
import java.net.*;
public class client {
public static void main(String[] args) throws Exception{
Socket s=new Socket(String.valueOf(InetAddress.getLocalHost()).split("/")[1],5000);
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String in="";
String out="";
while(!in.equals("stop"))
{
System.out.print("Client: ");
out=br.readLine();
dout.writeUTF(out);
dout.flush();
in=din.readUTF();
System.out.println("Server: "+in);
}
dout.close();
s.close();
}
}