List of usage examples for java.nio.channels SocketChannel validOps
public final int validOps()
From source file:org.openhab.binding.irtrans.handler.EthernetBridgeHandler.java
protected void onAcceptable() { lock.lock();// w w w . j av a 2 s . c om try { try { selector.selectNow(); } catch (IOException e) { logger.debug("An exception occurred while selecting: {}", e.getMessage()); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); } Iterator<SelectionKey> it = selector.selectedKeys().iterator(); while (it.hasNext()) { SelectionKey selKey = it.next(); it.remove(); if (selKey.isValid()) { if (selKey.isAcceptable() && selKey == listenerKey) { try { SocketChannel newChannel = listenerChannel.accept(); newChannel.configureBlocking(false); logger.trace("Received a connection request from '{}'", newChannel.getRemoteAddress()); synchronized (selector) { selector.wakeup(); newChannel.register(selector, newChannel.validOps()); } } catch (IOException e) { logger.debug("An exception occurred while accepting a connection on channel '{}': {}", listenerChannel, e.getMessage()); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); } } } } } finally { lock.unlock(); } }