示例#1
0
  /*
   * Static factory method for creating a secure ChannelIO object.
   * <P>
   * We need to allocate different sized application data buffers
   * based on whether we're secure or not.  We can't determine
   * this until our sslEngine is created.
   */
  static ChannelIOSecure getInstance(SocketChannel sc, boolean blocking, SSLContext sslc)
      throws IOException {

    ChannelIOSecure cio = new ChannelIOSecure(sc, blocking, sslc);

    // Create a buffer using the normal expected application size we'll
    // be getting.  This may change, depending on the peer's
    // SSL implementation.
    cio.appBBSize = cio.sslEngine.getSession().getApplicationBufferSize();
    cio.requestBB = ByteBuffer.allocate(cio.appBBSize);

    return cio;
  }
示例#2
0
  void runServer() throws Exception {
    for (; ; ) {

      SocketChannel sc = ssc.accept();

      ChannelIO cio =
          (sslContext != null
              ? ChannelIOSecure.getInstance(sc, true /* blocking */, sslContext)
              : ChannelIO.getInstance(sc, true /* blocking */));

      RequestServicer svc = new RequestServicer(cio);
      svc.run();
    }
  }