private static async Task GetStream()

in src/DotPulsar/Internal/Connector.cs [63:94]


    private static async Task<Stream> GetStream(string host, int port, CancellationToken cancellationToken)
    {
        var tcpClient = new TcpClient
        {
            ReceiveTimeout = 30000,
            SendTimeout = 30000
        };

        try
        {
            var type = Uri.CheckHostName(host);

#if NETSTANDARD2_0 || NETSTANDARD2_1
            if (type == UriHostNameType.IPv4 || type == UriHostNameType.IPv6)
                await tcpClient.ConnectAsync(IPAddress.Parse(host), port).ConfigureAwait(false);
            else
                await tcpClient.ConnectAsync(host, port).ConfigureAwait(false);
#else
            if (type == UriHostNameType.IPv4 || type == UriHostNameType.IPv6)
                await tcpClient.ConnectAsync(IPAddress.Parse(host), port, cancellationToken).ConfigureAwait(false);
            else
                await tcpClient.ConnectAsync(host, port, cancellationToken).ConfigureAwait(false);
#endif

            return tcpClient.GetStream();
        }
        catch
        {
            tcpClient.Dispose();
            throw;
        }
    }