Example #1
0
        public static async Task <WebSocketClient> ConnectToAsync(AddrPort dest, string path,
                                                                  int timeout, CancellationToken ct)
        {
            Socket socket = await NaiveUtils.ConnectTcpAsync(dest, timeout, async x => x, ct);

            try {
                var socketStream = MyStream.FromSocket(socket);
                var ws           = new WebSocketClient(MyStream.ToStream(socketStream), path);
                ws.Host = dest.Host;
                return(ws);
            } catch (Exception) {
                socket.Dispose();
                throw;
            }
        }