01: /**
02: * Client program requesting current date from server.
03: *
04: * Figure 4.19
05: *
06: * @author Gagne, Galvin, Silberschatz
07: * Operating System Concepts with Java - Sixth Edition
08: * Copyright John Wiley & Sons - 2003.
09: */
10:
11: import java.net.*;
12: import java.io.*;
13:
14: public class DateClient
15: {
16: public static void main(String[] args) throws IOException {
17: InputStream in = null;
18: BufferedReader bin = null;
19: Socket sock = null;
20:
21: try {
22: sock = new Socket("127.0.0.1",6013);
23: in = sock.getInputStream();
24: bin = new BufferedReader(new InputStreamReader(in));
25:
26: String line;
27: while( (line = bin.readLine()) != null)
28: System.out.println(line);
29: }
30: catch (IOException ioe) {
31: System.err.println(ioe);
32: }
33: finally {
34: sock.close();
35: }
36: }
37: }