public class Client extends Thread
1: import java.io.*;
2: import java.net.*;
3: import java.util.*;
4:
5: public class Client extends Thread
6: {
7: Socket clientSocket = null;
8:
9: public Client(Socket s)
10: {
11: clientSocket = s;
12: }
13:
14: public void run()
15: {
16: if (clientSocket == null)
17: {
18: return;
19: }
20:
21: PrintStream out = null;
22:
23: Utilities.printMsg("creating output stream");
24:
25: try
26: {
27: out = new PrintStream(clientSocket.getOutputStream(), true);
28: }
29: catch (IOException e)
30: {
31: System.err.println("Error binding output to socket, " + e);
32: System.exit(1);
33: }
34:
35: Utilities.printMsg("writing current date");
36:
37: Date d = new Date();
38: out.println(d);
39:
40: try
41: {
42: out.close();
43: clientSocket.close();
44: }
45: catch (IOException e)
46: {
47: }
48: }
49:
50: protected void finalize()
51: {
52: if (clientSocket != null)
53: {
54: try
55: {
56: clientSocket.close();
57: }
58: catch (IOException e)
59: {
60: }
61: clientSocket = null;
62: }
63: }
64: }