01: package org.methodize.nntprss.nntp;
02:
03: /* -----------------------------------------------------------
04: * nntp//rss - a bridge between the RSS world and NNTP clients
05: * Copyright (c) 2002, 2003 Jason Brome. All Rights Reserved.
06: *
07: * email: nntprss@methodize.org
08: * mail: Methodize Solutions
09: * PO Box 3865
10: * Grand Central Station
11: * New York NY 10163
12: *
13: * This file is part of nntp//rss
14: *
15: * nntp//rss is free software; you can redistribute it
16: * and/or modify it under the terms of the GNU General
17: * Public License as published by the Free Software Foundation;
18: * either version 2 of the License, or (at your option) any
19: * later version.
20: *
21: * This program is distributed in the hope that it will be
22: * useful, but WITHOUT ANY WARRANTY; without even the implied
23: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
24: * PURPOSE. See the GNU General Public License for more
25: * details.
26: *
27: * You should have received a copy of the GNU General Public
28: * License along with this program; if not, write to the
29: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
30: * Boston, MA 02111-1307 USA
31: * ----------------------------------------------------- */
32:
33: import java.io.IOException;
34: import java.net.ServerSocket;
35: import java.net.Socket;
36:
37: import org.apache.log4j.Logger;
38:
39: /**
40: * @author Jason Brome <jason@methodize.org>
41: * @version $Id: NNTPServerListener.java,v 1.2 2003/01/22 05:07:39 jasonbrome Exp $
42: */
43: public class NNTPServerListener extends Thread {
44:
45: private Logger log = Logger.getLogger(NNTPServerListener.class);
46:
47: private ServerSocket serverSocket = null;
48: private boolean active = true;
49: private NNTPServer nntpServer = null;
50:
51: public NNTPServerListener(NNTPServer nntpServer, int port)
52: throws Exception {
53: serverSocket = new ServerSocket(port);
54: this .nntpServer = nntpServer;
55: }
56:
57: public synchronized void shutdown() {
58: active = false;
59: this .notify();
60: }
61:
62: /**
63: * @see java.lang.Runnable#run()
64: */
65: public void run() {
66: while (active) {
67: try {
68: Socket clientSocket = serverSocket.accept();
69:
70: clientSocket.setTcpNoDelay(true);
71:
72: if (log.isInfoEnabled()) {
73: log.info("NNTP Client connection");
74: // log.info(
75: // "NNTP Client connection from "
76: // + clientSocket.getInetAddress());
77: }
78:
79: nntpServer.handleConnection(clientSocket);
80: } catch (IOException ie) {
81: // FIXME what to do???
82: }
83: }
84: }
85:
86: }
|