Code example for SocketChannel

Methods: configureBlocking, socket

0
      throws IOException { 
    socketChannel_ = socketChannel;
    socketAddress_ = socketAddress;
 
    // make it a nonblocking channel 
    socketChannel.configureBlocking(false);
 
    // set options 
    Socket socket = socketChannel.socket();
    socket.setSoLinger(false, 0);
    socket.setTcpNoDelay(true);
    setTimeout(timeout);
  } 
 
  /** 
   * Register the new SocketChannel with our Selector, indicating 
   * we'd like to be notified when it's ready for I/O. 
   * 
   * @param selector 
   * @return the selection key for this socket. 
   */