src/main/java/com/hibegin/http/server/handler/SSLReadWriteSelectorHandler.java
private int doWrite(ByteBuffer src) throws IOException {
        int retValue = 0;

        if (outNetBB.hasRemaining() && !tryFlush(outNetBB)) {
            return retValue;
        }

	/*
     * The data buffer is empty, we can reuse the entire buffer.
	 */
        outNetBB.clear();

        SSLEngineResult result = sslEngine.wrap(src, outNetBB);
        retValue = result.bytesConsumed();

        outNetBB.flip();

        switch (result.getStatus()) {

            case OK:
                if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
                    doTasks();
                }
                break;

            default:
                throw new IOException("sslEngine error during data write: " +
                        result.getStatus());
        }

	/*
     * Try to flush the data, regardless of whether or not
	 * it's been selected.  Odds of a write buffer being full
	 * is less than a read buffer being empty.
	 */
        tryFlush(src);
        if (outNetBB.hasRemaining()) {
            tryFlush(outNetBB);
        }

        return retValue;
    }
private int doWrite(ByteBuffer src) throws IOException {
        int retValue = 0;

        if (outNetBB.hasRemaining() && !tryFlush(outNetBB)) {
            return retValue;
        }

	/*
     * The data buffer is empty, we can reuse the entire buffer.
	 */
        outNetBB.clear();

        SSLEngineResult result = sslEngine.wrap(src, outNetBB);
        retValue = result.bytesConsumed();

        outNetBB.flip();

        switch (result.getStatus()) {

            case OK:
                if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
                    doTasks();
                }
                break;

            default:
                throw new IOException("sslEngine error during data write: " +
                        result.getStatus());
        }

	/*
     * Try to flush the data, regardless of whether or not
	 * it's been selected.  Odds of a write buffer being full
	 * is less than a read buffer being empty.
	 */
        tryFlush(src);
        if (outNetBB.hasRemaining()) {
            tryFlush(outNetBB);
        }

        return retValue;
    }
private int doWrite ( ByteBuffer src ) throws IOException { int retValue = 0 ; if ( outNetBB . hasRemaining ( ) && ! tryFlush ( outNetBB ) ) { return retValue ; } /*
     * The data buffer is empty, we can reuse the entire buffer.
	 */ outNetBB . clear ( ) ; SSLEngineResult result = sslEngine . wrap ( src , outNetBB ) ; retValue = result . bytesConsumed ( ) ; outNetBB . flip ( ) ; switch ( result . getStatus ( ) ) { case OK : if ( result . getHandshakeStatus ( ) == HandshakeStatus . NEED_TASK ) { doTasks ( ) ; } break ; default : throw new IOException ( "sslEngine error during data write: " + result . getStatus ( ) ) ; } /*
     * Try to flush the data, regardless of whether or not
	 * it's been selected.  Odds of a write buffer being full
	 * is less than a read buffer being empty.
	 */ tryFlush ( src ) ; if ( outNetBB . hasRemaining ( ) ) { tryFlush ( outNetBB ) ; } return retValue ; }
/*
Try to flush out any existing outbound data, then try to wrap
anything new contained in the src buffer.
<P>
Return the number of bytes actually consumed from the buffer,
but the data may actually be still sitting in the output buffer,
waiting to be flushed.
/ * Try to flush out any existing outbound data then try to wrap anything new contained in the src buffer . <P > Return the number of bytes actually consumed from the buffer but the data may actually be still sitting in the output buffer waiting to be flushed .