Code example for ServerSocketChannel

Methods: configureBlocking, register

0
this.server = server;
		this.bindEndpoint = bindEndpoint;
 
		socketChannel = ServerSocketChannel.open();
		socketChannel.configureBlocking(false);
 
		acceptSelector = Selector.open();
		socketChannel.register(acceptSelector, SelectionKey.OP_ACCEPT);
 
		keepRunning = true;
	} 
 
	/** 
	 * Runs in a loop, accepting connections and forwarding them to the server 
	 */ 
	@Override 
	public void run() 
	{ 
		try { 
			socketChannel.socket().bind(bindEndpoint);