-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.java
More file actions
28 lines (24 loc) · 714 Bytes
/
client.java
File metadata and controls
28 lines (24 loc) · 714 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
import java.net.*;
import java.io.*;
public class client
{
public static void main(String[] args)throws Exception
{
Socket s=new Socket("localhost",4999);
DataInputStream in=new DataInputStream(s.getInputStream());
DataOutputStream out=new DataOutputStream(s.getOutputStream());
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
while(true)
{
System.out.print("-> : ");
String inp=bf.readLine();
out.writeUTF(inp);
if (inp.equalsIgnoreCase("bye"))
break;
String str=in.readUTF();
System.out.println("Server: "+str);
}
System.out.println("Connection closed");
s.close();
}
}