public StreamEngine (SocketChannel fd_, final Options options_, final String endpoint_) 
    {
        handle = fd_;
        inbuf = null;
        insize = 0;
        io_enabled = false;
        outbuf = null;
        outsize = 0;
        handshaking = true;
        session = null;
        options = options_;
        plugged = false;
        terminating = false;
        endpoint = endpoint_;
        socket = null;
        greeting = ByteBuffer.allocate (GREETING_SIZE);
        greeting_output_buffer = ByteBuffer.allocate (GREETING_SIZE);
        encoder = null;
        decoder = null;

        //  Put the socket into non-blocking mode.
        try {
            Utils.unblock_socket (handle);
            
            //  Set the socket buffer limits for the underlying socket.
            if (options.sndbuf != 0) {
                handle.socket().setSendBufferSize((int)options.sndbuf);
            }
            if (options.rcvbuf != 0) {
                handle.socket().setReceiveBufferSize((int)options.rcvbuf);
            }

        } catch (IOException e) {
            throw new ZError.IOException(e);
        }

    }