-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleClient.java
More file actions
34 lines (30 loc) · 958 Bytes
/
SimpleClient.java
File metadata and controls
34 lines (30 loc) · 958 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
29
30
31
32
33
34
import java.net.*;
import java.io.*;
//Name: Jakob Millen
//ID: 1507831
public class SimpleClient {
public static void main(String[] args){
if(args.length != 2){
System.err.println("Incorrect usage: <server> <port>");
return;
}
InetAddress ia;
try{
ia = InetAddress.getByName("localhost");
}catch(UnknownHostException e){
System.err.println("Unkown name for ip");
return;
}
Socket sock;
try{
sock = new Socket(ia, 51333);
BufferedReader read = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String serverResponse;
while((serverResponse = read.readLine()) != null){
System.out.println(serverResponse);
}
}catch(IOException e){
e.printStackTrace();
}
}
}