FileDocCategorySizeDatePackage
Acceptor.javaAPI DocSun JDK 1.5.0 Example2869Sat Jan 08 15:08:43 GMT 2005None

Acceptor

public class Acceptor extends Object implements Runnable
A Runnable class which sits in a loop accepting SocketChannels, then registers the Channels with the read/write Selector.
author
Mark Reinhold
author
Brad R. Wetmore
version
1.2, 04/07/26

Fields Summary
private ServerSocketChannel
ssc
private Dispatcher
d
private SSLContext
sslContext
Constructors Summary
Acceptor(ServerSocketChannel ssc, Dispatcher d, SSLContext sslContext)

	this.ssc = ssc;
	this.d = d;
	this.sslContext = sslContext;
    
Methods Summary
public voidrun()

	for (;;) {
	    try {
		SocketChannel sc = ssc.accept();

		ChannelIO cio = (sslContext != null ?
		    ChannelIOSecure.getInstance(
			sc, false /* non-blocking */, sslContext) :
		    ChannelIO.getInstance(
			sc, false /* non-blocking */));

		RequestHandler rh = new RequestHandler(cio);

		d.register(cio.getSocketChannel(), SelectionKey.OP_READ, rh);

	    } catch (IOException x) {
		x.printStackTrace();
		break;
	    }
	}