public class Client
1: import java.io.*;
2: import java.net.*;
3: import java.util.*;
4:
5: public class Client
6: {
7: public static void main(String [] args)
8: {
9: String theTime;
10:
11: try
12: {
13: Socket socket = new Socket("cs.smu.ca", 4444);
14: BufferedReader input = new
15: BufferedReader(new
16: InputStreamReader(socket.getInputStream()));
17: theTime = input.readLine();
18: System.out.println("The time at cs.smu.ca is " +
19: theTime + ". ");
20: socket.close();
21: }
22: catch (UnknownHostException e)
23: {
24: System.err.println("No such host. ");
25: }
26: catch (IOException io)
27: {
28: System.err.println(io.toString());
29: }
30: catch (Exception e)
31: {
32: System.out.println("Error: " + e.toString());
33: }
34: }
35: }
36: