private boolean enableKeepalive(PollController conn,boolean isNew) throws IOException {
  if (_selectMax <= _connectionCount.get()) {
    throw new IllegalStateException(this + " keepalive overflow " + _connectionCount+ " max="+ _selectMax);
  }
  JniSocketImpl socket=(JniSocketImpl)conn.getSocket();
  if (socket == null) {
    throw new IllegalStateException(this + " socket empty for " + conn);
  }
  int nativeFd=socket.getNativeFd();
  if (nativeFd < 0) {
    throw new IllegalStateException(this + " attempted keepalive with closed file descriptor fd=" + nativeFd+ "\n "+ socket+ "\n "+ conn);
  }
 else   if (_connections.length() <= nativeFd) {
    throw new IllegalStateException(this + " select overflow for file descriptor fd=" + nativeFd+ " "+ conn);
  }
  if (!_lifecycle.isActive()) {
    throw new IllegalStateException("inactive keepalive");
  }
  if (isNew) {
    setMaxConnection(nativeFd);
    _connections.set(nativeFd,conn);
    _connectionCount.incrementAndGet();
  }
  int result=addNative(_fd,nativeFd,isNew);
  return result == 0;
}

private boolean enableKeepalive ( PollController conn , boolean isNew ) throws IOException { if ( _selectMax <= _connectionCount . get ( ) ) { throw new IllegalStateException ( this + " keepalive overflow " + _connectionCount + " max=" + _selectMax ) ; } JniSocketImpl socket = ( JniSocketImpl ) conn . getSocket ( ) ; if ( socket == null ) { throw new IllegalStateException ( this + " socket empty for " + conn ) ; } int nativeFd = socket . getNativeFd ( ) ; if ( nativeFd < 0 ) { throw new IllegalStateException ( this + " attempted keepalive with closed file descriptor fd=" + nativeFd + "\n " + socket + "\n " + conn ) ; } else if ( _connections . length ( ) <= nativeFd ) { throw new IllegalStateException ( this + " select overflow for file descriptor fd=" + nativeFd + " " + conn ) ; } if ( ! _lifecycle . isActive ( ) ) { throw new IllegalStateException ( "inactive keepalive" ) ; } if ( isNew ) { setMaxConnection ( nativeFd ) ; _connections . set ( nativeFd , conn ) ; _connectionCount . incrementAndGet ( ) ; } int result = addNative ( _fd , nativeFd , isNew ) ; return result == 0 ; }
enables keepalive and checks to see if data is available .
