@Override
    public void write(ByteBuffer buffer) throws IOException {
        if (mIsClosed) {
            return;
        }
        if (!buffer.hasRemaining()) {
            return;
        }
        mPendingBuffers.offerLast(buffer);
        interestWrite();
    }
Read data from remote server and put it into the given buffer.

@param buffer A buffer to store data.
@return The read length.
@throws IOException if an I/O error occurs.
netbare-core/src/main/java/com/github/megatronking/netbare/tunnel/NioTunnel.java