public unsafe static extern IntPtr quiche_connect( byte *serverName, byte *scid, UIntPtr scid_len, QuicheConfig config);
/// <summary> /// Creates a new connection binding to the specified local endpoint, and using the specified config /// and a new auto-generated connection ID. /// </summary> /// <param name="localEndPoint">The local endpoint to bind to.</param> /// <param name="config">The <see cref="QuicheConfig"/> to use.</param> public QuicConnection(IPEndPoint localEndPoint, QuicheConfig config) : this(localEndPoint, QuicConnectionId.NewId(), config) { }
/// <summary> /// Creates a new connection using the specified config and connection ID. /// </summary> /// <param name="sourceConnectionId">The connection ID to use to identify the local end of the connection</param> /// <param name="config">The <see cref="QuicheConfig"/> to use.</param> public QuicConnection(QuicConnectionId sourceConnectionId, QuicheConfig config) { _config = config; _client = new UdpClient(); SourceConnectionId = sourceConnectionId; }
/// <summary> /// Creates a new connectionusing the specified config /// and a new auto-generated connection ID. /// </summary> /// <param name="localEndPoint">The local endpoint to bind to.</param> /// <param name="config">The <see cref="QuicheConfig"/> to use.</param> public QuicConnection(QuicheConfig config) : this(QuicConnectionId.NewId(), config) { }
private unsafe static IntPtr CreateNativeConnection(string serverName, QuicConnectionId scid, QuicheConfig config) { // PERF: We could stackalloc this if it's small enough. var buf = new byte[Encoding.UTF8.GetByteCount(serverName) + 1]; Encoding.UTF8.GetBytes(serverName, 0, serverName.Length, buf, 0); buf[buf.Length - 1] = 0; // Null terminator. fixed(byte *ptr = buf) { fixed(byte *scidPtr = scid.Value.Span) { return(NativeMethods.quiche_connect( ptr, scidPtr, (UIntPtr)scid.Value.Length, config)); } } }
/// <summary> /// Creates a new connection binding to the specified local endpoint, using the specified config and connection ID. /// </summary> /// <param name="localEndPoint">The remote endpoint to connect to</param> /// <param name="sourceConnectionId">The connection ID to use to identify the local end of the connection</param> /// <param name="config">The <see cref="QuicheConfig"/> to use.</param> public QuicConnection(IPEndPoint localEndPoint, QuicConnectionId sourceConnectionId, QuicheConfig config) { _config = config; _localEndPoint = localEndPoint; SourceConnectionId = sourceConnectionId; }