-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
25 lines (20 loc) · 593 Bytes
/
Client.java
File metadata and controls
25 lines (20 loc) · 593 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
package Networking;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.net.UnknownHostException;
public class Client {
public static void main(String[] args) throws UnknownHostException, IOException {
String serverIP = "localhost";
int serverport = 9001;
Socket socket = new Socket(serverIP, serverport);
InputStream is = socket.getInputStream();
System.out.println("Client Comes");
int singleChar = is.read();
while (singleChar != -1) {
System.out.print((char) singleChar);
singleChar = is.read();
}
socket.close();
}
}