private void processSessionRequests() throws IOReactorException {
ListenerEndpointImpl request;
while ((request = this.requestQueue.poll()) != null) {
SocketAddress address = request.getAddress();
ServerSocketChannel serverChannel;
try {
serverChannel = ServerSocketChannel.open();
serverChannel.configureBlocking(false);
} catch (IOException ex) {
throw new IOReactorException("Failure opening server socket", ex);
}
try {
serverChannel.socket().bind(address);
} catch (IOException ex) {
request.failed(ex);
if (this.exceptionHandler == null || !this.exceptionHandler.handle(ex)) {
throw new IOReactorException("Failure binding socket to address "
+ address, ex);
} else {
return;
}
}
try {
SelectionKey key = serverChannel.register(this.selector, SelectionKey.OP_ACCEPT);
key.attach(request);
request.setKey(key);
} catch (IOException ex) {
throw new IOReactorException("Failure registering channel " +
"with the selector", ex);
}
this.endpoints.add(request);
request.completed(serverChannel.socket().getLocalSocketAddress());
}
}