Пример #1
0
        private MsQuicStream StreamOpen(
            QUIC_STREAM_OPEN_FLAG flags)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Enter(this);
            }

            IntPtr streamPtr = IntPtr.Zero;

            MsQuicStatusException.ThrowIfFailed(
                MsQuicApi.Api.StreamOpenDelegate(
                    _ptr,
                    (uint)flags,
                    MsQuicStream.NativeCallbackHandler,
                    IntPtr.Zero,
                    out streamPtr));

            MsQuicStream stream = new MsQuicStream(this, flags, streamPtr, inbound: false);

            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Exit(this);
            }
            return(stream);
        }
Пример #2
0
 private void SetParam(
     QUIC_PARAM_SESSION param,
     MsQuicNativeMethods.QuicBuffer buf)
 {
     MsQuicStatusException.ThrowIfFailed(MsQuicApi.Api.UnsafeSetParam(
                                             _nativeObjPtr,
                                             (uint)QUIC_PARAM_LEVEL.SESSION,
                                             (uint)param,
                                             buf));
 }
Пример #3
0
        internal override ValueTask ConnectAsync(CancellationToken cancellationToken = default)
        {
            ThrowIfDisposed();

            MsQuicStatusException.ThrowIfFailed(
                MsQuicApi.Api.ConnectionStartDelegate(
                    _ptr,
                    (ushort)_remoteEndPoint.AddressFamily,
                    _remoteEndPoint.Address.ToString(),
                    (ushort)_remoteEndPoint.Port));

            return(_connectTcs.GetTypelessValueTask());
        }
Пример #4
0
        internal override void Start()
        {
            ThrowIfDisposed();

            SetCallbackHandler();

            SOCKADDR_INET address = MsQuicAddressHelpers.IPEndPointToINet(_listenEndPoint);

            MsQuicStatusException.ThrowIfFailed(MsQuicApi.Api.ListenerStartDelegate(
                                                    _ptr,
                                                    ref address));

            SetListenPort();
        }
Пример #5
0
        private ValueTask ShutdownAsync(
            QUIC_CONNECTION_SHUTDOWN_FLAG Flags,
            ushort ErrorCode)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Enter(this);
            }

            uint status = MsQuicApi.Api.ConnectionShutdownDelegate(
                _ptr,
                (uint)Flags,
                ErrorCode);

            MsQuicStatusException.ThrowIfFailed(status);

            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Exit(this);
            }
            return(_shutdownTcs.GetTypelessValueTask());
        }