KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > DxLib > net > DxMultiServerClient


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: DxMultiServerClient.java,v 1.9 2001/01/23 14:13:13 daniela Exp $
8

9 package org.ozoneDB.DxLib.net;
10
11 import java.net.*;
12 import java.io.*;
13 import org.ozoneDB.DxLib.*;
14
15
16 /**
17  * Thread, der staendig am entsprechenden port lauscht und eine neue
18  * Anfragen zum Server meldet.
19  *
20  *
21  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
22  * @version $Revision: 1.9 $Date: 2001/01/23 14:13:13 $
23  */

24 public class DxMultiServerClient extends DxClient implements Runnable JavaDoc {
25
26     boolean stop;
27
28     DxMultiServer server;
29
30     Thread JavaDoc thread;
31     
32     
33     public DxMultiServerClient( Socket socket, DxMultiServer dms ) throws IOException{
34         super( socket );
35         stop = false;
36         server = dms;
37         thread = dms.newThread( this );
38     }
39     
40     
41     public void run() {
42         try {
43             while (!stop) {
44                 server.handleClientEvent( this, receive() );
45             }
46             super.close();
47         } catch (Exception JavaDoc e) {
48             server.handleClientException( this, e );
49         }
50     }
51     
52     
53     public synchronized void listen() {
54         if (!thread.isAlive()) {
55             thread.start();
56         }
57     }
58     
59     
60     public synchronized void close() {
61         stop = true;
62     }
63     
64     
65     public Thread JavaDoc thread() {
66         return thread;
67     }
68 }
69
Popular Tags