01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: DxMultiServerClient.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.DxLib.net;
10:
11: import java.net.*;
12: import java.io.*;
13: import org.ozoneDB.DxLib.*;
14:
15: /**
16: * Thread, der staendig am entsprechenden port lauscht und eine neue
17: * Anfragen zum Server meldet.
18: *
19: *
20: * @author <a href="http://www.softwarebuero.de/">SMB</a>
21: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
22: */
23: public class DxMultiServerClient extends DxClient implements Runnable {
24:
25: boolean stop;
26:
27: DxMultiServer server;
28:
29: Thread thread;
30:
31: public DxMultiServerClient(Socket socket, DxMultiServer dms)
32: throws IOException {
33: super (socket);
34: stop = false;
35: server = dms;
36: thread = dms.newThread(this );
37: }
38:
39: public void run() {
40: try {
41: while (!stop) {
42: server.handleClientEvent(this , receive());
43: }
44: super .close();
45: } catch (Exception e) {
46: server.handleClientException(this , e);
47: }
48: }
49:
50: public synchronized void listen() {
51: if (!thread.isAlive()) {
52: thread.start();
53: }
54: }
55:
56: public synchronized void close() {
57: stop = true;
58: }
59:
60: public Thread thread() {
61: return thread;
62: }
63: }
|