chris@0: /* chris@0: * StarOffice News Server chris@0: * see AUTHORS for the list of contributors chris@0: * chris@0: * This program is free software: you can redistribute it and/or modify chris@0: * it under the terms of the GNU General Public License as published by chris@0: * the Free Software Foundation, either version 3 of the License, or chris@0: * (at your option) any later version. chris@0: * chris@0: * This program is distributed in the hope that it will be useful, chris@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of chris@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the chris@0: * GNU General Public License for more details. chris@0: * chris@0: * You should have received a copy of the GNU General Public License chris@0: * along with this program. If not, see . chris@0: */ chris@0: chris@0: package com.so.news; chris@0: chris@0: import java.io.IOException; chris@0: import java.net.ServerSocket; chris@0: chris@0: /** chris@0: * Server component of the n3tpd. chris@0: * @author Christian Lins chris@0: * @author Dennis Schwerdel chris@0: */ chris@0: public class NNTPDaemon extends Thread chris@0: { chris@0: private ServerSocket socket; chris@0: chris@0: public NNTPDaemon(boolean aux) throws IOException chris@0: { chris@0: int port; chris@0: if(!aux) chris@0: port = Config.getInstance().get("n3tpd.port", 119); chris@0: else chris@0: port = Config.getInstance().get("n3tpd.auxport", 8080); chris@0: chris@0: int backlog = Config.getInstance().get("n3tpd.server.backlog", 10); chris@0: chris@0: // Create and bind the socket chris@0: socket = new ServerSocket(port, backlog); chris@0: } chris@0: chris@0: @Override chris@0: public void run() chris@0: { chris@0: System.out.println("Daemon listening on port " + socket.getLocalPort() + " ..."); chris@0: chris@0: while(isAlive() && !isInterrupted()) chris@0: { chris@0: try chris@0: { chris@0: new NNTPConnection(socket.accept()).start(); chris@0: } chris@0: catch (Exception e) chris@0: { chris@0: e.printStackTrace(); chris@0: } chris@0: } chris@0: } chris@0: }