title: Java nio SocketChannel failed to create
body: <p>I've got this:</p>
  
  <pre><code>Selector selector = Selector.open();
  ServerSocketChannel listenChannel = ServerSocketChannel.open();
  listenChannel.socket().bind(new InetSocketAddress(12112));
  listenChannel.register(selector, SelectionKey.OP_ACCEPT);
  </code></pre>
  
  <p>Just 4 lines of code inside main(), and the last line throws out exception:</p>
  
  <pre><code>java.nio.channels.IllegalBlockingModeException
  at java.nio.channels.spi.AbstractSelectableChannel.register(AbstractSelectableChannel.java:201)
  at java.nio.channels.SelectableChannel.register(SelectableChannel.java:280)
  at myServer.main(myServer.java:18)
  </code></pre>
  
  <p>I just wish to create a ServerSocketChannel and register it to a Selector. What's wrong here, how to fix?</p>
  
  <p>Thanks.</p>