-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
27 lines (25 loc) · 894 Bytes
/
Copy pathClient.java
File metadata and controls
27 lines (25 loc) · 894 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
package SocketProgramming;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;
public class Client {
public static void main(String[] args)throws Exception {
Socket sco=new Socket(InetAddress.getLocalHost(),9998);
Scanner sc=new Scanner(System.in);
System.out.println("Type done to end");
while(true) {
DataInputStream in = new DataInputStream(sco.getInputStream());
System.out.println("Server :");
System.out.println(in.readUTF());
System.out.println("Client :");
DataOutputStream out = new DataOutputStream(sco.getOutputStream());
String msg= sc.next();
out.writeUTF(msg);
if("done".equalsIgnoreCase(msg))
break;
}
sco.close();
}
}