/** * Add a listening port and create an Acceptor thread which accepts * new connections on this port. * * @param factory The connection factory for new connections * on this port * @param port The port we are going to listen to. */ public synchronized void listen(ConnectionFactory factory, int port) throws IOException { // make sure we have only one acceptor per listen port if (acceptors.containsKey(port)) { log.warning("Already listening to port=" + port); return; } Acceptor a = new Acceptor(this, factory, port); // inherit the fatal error handling of listener if (fatalErrorHandler != null) { a.setFatalErrorHandler(fatalErrorHandler); } a.listen().start(); acceptors.put(port, a); }
while (!isInterrupted()) {