mirror of
https://github.com/Azure/DotNetty.git
synced 2026-10-18 22:30:36 +08:00
b2f10c28cb
Motivation: SocketException and ODE are being thrown when disconnecting gracefully. Modifications: - dismiss async read completion if it is done on inactive channel - do not attempt sync-reading from a socket that is not Connected - extra: fixing echo sample with better practices - extra: ReadListener for more natural test scenarios - extra: tweaked nbench spec to work in-loop Result: No excessive errors happen during graceful shutdown
24 lines
759 B
C#
24 lines
759 B
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
namespace DotNetty.Tests.Common
|
|
{
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using DotNetty.Transport.Channels;
|
|
|
|
public static class ChannelExtensions
|
|
{
|
|
public static Task WriteAndFlushManyAsync(this IChannel channel, params object[] messages)
|
|
{
|
|
var list = new List<Task>();
|
|
foreach (object m in messages)
|
|
{
|
|
list.Add(channel.WriteAsync(m));
|
|
}
|
|
IEnumerable<Task> tasks = list.ToArray();
|
|
channel.Flush();
|
|
return Task.WhenAll(tasks);
|
|
}
|
|
}
|
|
} |