private Task AddTask(TcpClient client, CancellationToken ct) { Console.WriteLine($"Client {client.Client.RemoteEndPoint} connected."); var c = new MyTcpClient(client, logger); var task = this.HandleClient(c, ct); this.tasks.Add(task); return(this.ResetCleanUp()); }
private async Task <MyTcpClient> HandleClient(MyTcpClient client, CancellationToken ct) { using (var stream = client.GetStream()) { var buffer = new byte[256]; await stream.ReadAsync(buffer, 0, buffer.Length, ct).ConfigureAwait(false); } return(client); }