Semester_2/IntroOS/OSC10e/ch3/DateClient.java
<reponame>anhkhoakz/TDTU<filename>Semester_2/IntroOS/OSC10e/ch3/DateClient.java
/**
 * Client program requesting current date from server.
 *
 * Figure 3.28
 *
 * @author Silberschatz, Gagne and Galvin
 * Operating System Concepts  - Tenth Edition
 */

import java.net.*;
import java.io.*;

public class DateClient {
	public static void main(String[] args) {
		try {
			// this could be changed to an IP name or address other than the localhost
			Socket sock = new Socket("127.0.0.1", 6013);
			InputStream in = sock.getInputStream();
			BufferedReader bin = new BufferedReader(new InputStreamReader(in));

			String line;
			while ((line = bin.readLine()) != null)
				System.out.println(line);

			sock.close();
		} catch (IOException ioe) {
			System.err.println(ioe);
		}
	}
}
