You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -4,7 +4,7 @@
|
||||
|
||||
using System.Net.Test.Common;
|
||||
using System.Threading;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // Unix platforms don't yet support receiving data with AcceptAsync.
|
||||
public void AcceptAsync_WithReceiveBuffer_Success()
|
||||
{
|
||||
Assert.True(Capability.IPv4Support());
|
||||
@@ -169,7 +169,116 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // Unix platforms don't yet support receiving data with AcceptAsync.
|
||||
public void AcceptAsync_WithTooSmallReceiveBuffer_Failure()
|
||||
{
|
||||
using (Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
int port = server.BindToAnonymousPort(IPAddress.Loopback);
|
||||
server.Listen(1);
|
||||
|
||||
SocketAsyncEventArgs acceptArgs = new SocketAsyncEventArgs();
|
||||
acceptArgs.Completed += OnAcceptCompleted;
|
||||
acceptArgs.UserToken = new ManualResetEvent(false);
|
||||
|
||||
byte[] buffer = new byte[1];
|
||||
acceptArgs.SetBuffer(buffer, 0, buffer.Length);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => server.AcceptAsync(acceptArgs));
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[ActiveIssue(17209, TestPlatforms.AnyUnix)]
|
||||
public void AcceptAsync_WithTargetSocket_Success()
|
||||
{
|
||||
using (Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
int port = listener.BindToAnonymousPort(IPAddress.Loopback);
|
||||
listener.Listen(1);
|
||||
|
||||
Task<Socket> acceptTask = listener.AcceptAsync(server);
|
||||
client.Connect(IPAddress.Loopback, port);
|
||||
Assert.Same(server, acceptTask.Result);
|
||||
}
|
||||
}
|
||||
|
||||
[ActiveIssue(17209, TestPlatforms.AnyUnix)]
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public void AcceptAsync_WithTargetSocket_ReuseAfterDisconnect_Success(bool reuseSocket)
|
||||
{
|
||||
using (var listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (var server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (var saea = new SocketAsyncEventArgs())
|
||||
{
|
||||
int port = listener.BindToAnonymousPort(IPAddress.Loopback);
|
||||
listener.Listen(1);
|
||||
|
||||
var are = new AutoResetEvent(false);
|
||||
saea.Completed += delegate { are.Set(); };
|
||||
saea.AcceptSocket = server;
|
||||
|
||||
using (var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.True(listener.AcceptAsync(saea));
|
||||
client.Connect(IPAddress.Loopback, port);
|
||||
are.WaitOne();
|
||||
Assert.Same(server, saea.AcceptSocket);
|
||||
Assert.True(server.Connected);
|
||||
}
|
||||
|
||||
server.Disconnect(reuseSocket);
|
||||
Assert.False(server.Connected);
|
||||
|
||||
if (reuseSocket)
|
||||
{
|
||||
using (var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.True(listener.AcceptAsync(saea));
|
||||
client.Connect(IPAddress.Loopback, port);
|
||||
are.WaitOne();
|
||||
Assert.Same(server, saea.AcceptSocket);
|
||||
Assert.True(server.Connected);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (listener.AcceptAsync(saea))
|
||||
{
|
||||
are.WaitOne();
|
||||
}
|
||||
Assert.Equal(SocketError.InvalidArgument, saea.SocketError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[ActiveIssue(17209, TestPlatforms.AnyUnix)]
|
||||
public void AcceptAsync_WithAlreadyBoundTargetSocket_Failed()
|
||||
{
|
||||
using (Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
int port = listener.BindToAnonymousPort(IPAddress.Loopback);
|
||||
listener.Listen(1);
|
||||
|
||||
server.BindToAnonymousPort(IPAddress.Loopback);
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => { listener.AcceptAsync(server); });
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)] // Unix platforms don't yet support receiving data with AcceptAsync.
|
||||
public void AcceptAsync_WithReceiveBuffer_Failure()
|
||||
{
|
||||
//
|
||||
@@ -193,21 +302,5 @@ namespace System.Net.Sockets.Tests
|
||||
Assert.Throws<PlatformNotSupportedException>(() => server.AcceptAsync(acceptArgs));
|
||||
}
|
||||
}
|
||||
|
||||
#region GC Finalizer test
|
||||
// This test assumes sequential execution of tests and that it is going to be executed after other tests
|
||||
// that used Sockets.
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
public void TestFinalizers()
|
||||
{
|
||||
// Making several passes through the FReachable list.
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -114,7 +114,7 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Theory]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // Unix platforms do not support TcpListener.AllowNatTraversal
|
||||
[InlineData(true, IPProtectionLevel.Unrestricted)]
|
||||
[InlineData(false, IPProtectionLevel.EdgeRestricted)]
|
||||
public void AllowNatTraversal_Windows(bool allow, IPProtectionLevel resultLevel)
|
||||
@@ -126,7 +126,7 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Theory]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)] // Unix platforms do not support TcpListener.AllowNatTraversal
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void AllowNatTraversal_AnyUnix(bool allow)
|
||||
@@ -134,22 +134,5 @@ namespace System.Net.Sockets.Tests
|
||||
var l = new TcpListener(IPAddress.Any, 0);
|
||||
Assert.Throws<PlatformNotSupportedException>(() => l.AllowNatTraversal(allow));
|
||||
}
|
||||
|
||||
|
||||
#region GC Finalizer test
|
||||
// This test assumes sequential execution of tests and that it is going to be executed after other tests
|
||||
// that used Sockets.
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
public void TestFinalizers()
|
||||
{
|
||||
// Making several passes through the FReachable list.
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
|
||||
using System.Net.Test.Common;
|
||||
using System.Threading;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
@@ -81,5 +81,36 @@ namespace System.Net.Sockets.Tests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Theory]
|
||||
[InlineData(AddressFamily.InterNetwork)]
|
||||
[InlineData(AddressFamily.InterNetworkV6)]
|
||||
public async Task ConnectTaskAsync_IPAddresss_Success(AddressFamily family)
|
||||
{
|
||||
int port;
|
||||
using (SocketTestServer.SocketTestServerFactory(SocketImplementationType.Async, family == AddressFamily.InterNetwork ? IPAddress.Loopback : IPAddress.IPv6Loopback, out port))
|
||||
using (Socket client = new Socket(family, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
await client.ConnectAsync(new IPAddress[] { IPAddress.Loopback, IPAddress.IPv6Loopback }, port);
|
||||
Assert.True(client.Connected);
|
||||
}
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // Unix currently does not support Disconnect
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
public async Task Connect_AfterDisconnect_Fails()
|
||||
{
|
||||
int port;
|
||||
using (SocketTestServer.SocketTestServerFactory(SocketImplementationType.Async, IPAddress.Loopback, out port))
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
await client.ConnectAsync(IPAddress.Loopback, port);
|
||||
client.Disconnect(reuseSocket: false);
|
||||
Assert.Throws<InvalidOperationException>(() => client.Connect(IPAddress.Loopback, port));
|
||||
Assert.Throws<InvalidOperationException>(() => client.Connect(new IPEndPoint(IPAddress.Loopback, port)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -74,21 +74,5 @@ namespace System.Net.Sockets.Tests
|
||||
server6.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#region GC Finalizer test
|
||||
// This test assumes sequential execution of tests and that it is going to be executed after other tests
|
||||
// that used Sockets.
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
public void TestFinalizers()
|
||||
{
|
||||
// Making several passes through the FReachable list.
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
using System.Net.Test.Common;
|
||||
using System.Threading;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
@@ -26,9 +26,25 @@ namespace System.Net.Sockets.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidArguments_Throw()
|
||||
{
|
||||
using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("asyncResult", () => s.EndDisconnect(null));
|
||||
Assert.Throws<ArgumentException>("asyncResult", () => s.EndDisconnect(Task.CompletedTask));
|
||||
s.Dispose();
|
||||
Assert.Throws<ObjectDisposedException>(() => s.Disconnect(true));
|
||||
Assert.Throws<ObjectDisposedException>(() => s.BeginDisconnect(true, null, null));
|
||||
Assert.Throws<ObjectDisposedException>(() => s.EndDisconnect(null));
|
||||
Assert.Throws<ObjectDisposedException>(() => { s.DisconnectAsync(null); });
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
[OuterLoop("Issue #11345")]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void Disconnect_Success()
|
||||
public void Disconnect_Success(bool reuseSocket)
|
||||
{
|
||||
AutoResetEvent completed = new AutoResetEvent(false);
|
||||
|
||||
@@ -40,29 +56,36 @@ namespace System.Net.Sockets.Tests
|
||||
args.Completed += OnCompleted;
|
||||
args.UserToken = completed;
|
||||
args.RemoteEndPoint = server1.EndPoint;
|
||||
args.DisconnectReuseSocket = true;
|
||||
args.DisconnectReuseSocket = reuseSocket;
|
||||
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.True(client.ConnectAsync(args));
|
||||
completed.WaitOne();
|
||||
if (client.ConnectAsync(args))
|
||||
{
|
||||
completed.WaitOne();
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
|
||||
client.Disconnect(true);
|
||||
client.Disconnect(reuseSocket);
|
||||
|
||||
args.RemoteEndPoint = server2.EndPoint;
|
||||
|
||||
Assert.True(client.ConnectAsync(args));
|
||||
completed.WaitOne();
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
if (client.ConnectAsync(args))
|
||||
{
|
||||
completed.WaitOne();
|
||||
}
|
||||
|
||||
Assert.Equal(reuseSocket ? SocketError.Success : SocketError.IsConnected, args.SocketError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
[OuterLoop("Issue #11345")]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void DisconnectAsync_Success()
|
||||
public void DisconnectAsync_Success(bool reuseSocket)
|
||||
{
|
||||
AutoResetEvent completed = new AutoResetEvent(false);
|
||||
|
||||
@@ -74,31 +97,41 @@ namespace System.Net.Sockets.Tests
|
||||
args.Completed += OnCompleted;
|
||||
args.UserToken = completed;
|
||||
args.RemoteEndPoint = server1.EndPoint;
|
||||
args.DisconnectReuseSocket = true;
|
||||
args.DisconnectReuseSocket = reuseSocket;
|
||||
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.True(client.ConnectAsync(args));
|
||||
completed.WaitOne();
|
||||
if (client.ConnectAsync(args))
|
||||
{
|
||||
completed.WaitOne();
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
|
||||
Assert.True(client.DisconnectAsync(args));
|
||||
completed.WaitOne();
|
||||
if (client.DisconnectAsync(args))
|
||||
{
|
||||
completed.WaitOne();
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
|
||||
args.RemoteEndPoint = server2.EndPoint;
|
||||
|
||||
Assert.True(client.ConnectAsync(args));
|
||||
completed.WaitOne();
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
if (client.ConnectAsync(args))
|
||||
{
|
||||
completed.WaitOne();
|
||||
}
|
||||
|
||||
Assert.Equal(reuseSocket ? SocketError.Success : SocketError.IsConnected, args.SocketError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
[OuterLoop("Issue #11345")]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void BeginDisconnect_Success()
|
||||
public void BeginDisconnect_Success(bool reuseSocket)
|
||||
{
|
||||
AutoResetEvent completed = new AutoResetEvent(false);
|
||||
|
||||
@@ -113,51 +146,27 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.True(client.ConnectAsync(args));
|
||||
completed.WaitOne();
|
||||
if (client.ConnectAsync(args))
|
||||
{
|
||||
completed.WaitOne();
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
|
||||
client.EndDisconnect(client.BeginDisconnect(true, null, null));
|
||||
IAsyncResult ar = client.BeginDisconnect(reuseSocket, null, null);
|
||||
client.EndDisconnect(ar);
|
||||
Assert.Throws<InvalidOperationException>(() => client.EndDisconnect(ar));
|
||||
|
||||
args.RemoteEndPoint = server2.EndPoint;
|
||||
|
||||
Assert.True(client.ConnectAsync(args));
|
||||
completed.WaitOne();
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
if (client.ConnectAsync(args))
|
||||
{
|
||||
completed.WaitOne();
|
||||
}
|
||||
|
||||
Assert.Equal(reuseSocket ? SocketError.Success : SocketError.IsConnected, args.SocketError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(~TestPlatforms.Windows)]
|
||||
public void Disconnect_NonWindows_NotSupported()
|
||||
{
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.Throws<PlatformNotSupportedException>(() => client.Disconnect(true));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(~TestPlatforms.Windows)]
|
||||
public void DisconnectAsync_NonWindows_NotSupported()
|
||||
{
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
|
||||
args.DisconnectReuseSocket = true;
|
||||
Assert.Throws<PlatformNotSupportedException>(() => client.DisconnectAsync(args));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(~TestPlatforms.Windows)]
|
||||
public void BeginDisconnect_NonWindows_NotSupported()
|
||||
{
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.Throws<PlatformNotSupportedException>(() => client.BeginDisconnect(true, null, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Xunit;
|
||||
@@ -33,6 +32,13 @@ namespace System.Net.Sockets.Tests
|
||||
Assert.Throws<ObjectDisposedException>(() => GetDisposedSocket().Available);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IOControl_Throws_ObjectDisposed()
|
||||
{
|
||||
Assert.Throws<ObjectDisposedException>(() => GetDisposedSocket().IOControl(0, null, null));
|
||||
Assert.Throws<ObjectDisposedException>(() => GetDisposedSocket().IOControl(IOControlCode.AsyncIO, null, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LocalEndPoint_Throws_ObjectDisposed()
|
||||
{
|
||||
|
@@ -32,22 +32,38 @@ namespace System.Net.Sockets.Tests
|
||||
[Theory]
|
||||
[InlineData(SocketImplementationType.APM)]
|
||||
[InlineData(SocketImplementationType.Async)]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void Socket_ConnectDnsEndPoint_Success(SocketImplementationType type)
|
||||
{
|
||||
int port;
|
||||
SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port);
|
||||
using (SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port))
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
sock.Connect(new DnsEndPoint("localhost", port));
|
||||
}
|
||||
}
|
||||
|
||||
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
sock.Connect(new DnsEndPoint("localhost", port));
|
||||
|
||||
sock.Dispose();
|
||||
server.Dispose();
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Theory]
|
||||
[InlineData(SocketImplementationType.APM)]
|
||||
[InlineData(SocketImplementationType.Async)]
|
||||
public void Socket_ConnectDnsEndPoint_SetSocketProperties_Success(SocketImplementationType type)
|
||||
{
|
||||
int port;
|
||||
using (SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port))
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
sock.LingerState = new LingerOption(false, 0);
|
||||
sock.NoDelay = true;
|
||||
sock.ReceiveBufferSize = 1024;
|
||||
sock.ReceiveTimeout = 100;
|
||||
sock.SendBufferSize = 1024;
|
||||
sock.SendTimeout = 100;
|
||||
sock.Connect(new DnsEndPoint("localhost", port));
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void Socket_ConnectDnsEndPoint_Failure()
|
||||
{
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
@@ -59,7 +75,7 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
SocketError errorCode = ex.SocketErrorCode;
|
||||
Assert.True((errorCode == SocketError.HostNotFound) || (errorCode == SocketError.NoData),
|
||||
"SocketErrorCode: {0}" + errorCode);
|
||||
$"SocketErrorCode: {errorCode}");
|
||||
|
||||
ex = Assert.ThrowsAny<SocketException>(() =>
|
||||
{
|
||||
@@ -103,23 +119,41 @@ namespace System.Net.Sockets.Tests
|
||||
[Theory]
|
||||
[InlineData(SocketImplementationType.APM)]
|
||||
[InlineData(SocketImplementationType.Async)]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void Socket_BeginConnectDnsEndPoint_Success(SocketImplementationType type)
|
||||
{
|
||||
int port;
|
||||
SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port);
|
||||
using (SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port))
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
IAsyncResult result = sock.BeginConnect(new DnsEndPoint("localhost", port), null, null);
|
||||
sock.EndConnect(result);
|
||||
Assert.Throws<InvalidOperationException>(() => sock.EndConnect(result)); // validate can't call end twice
|
||||
}
|
||||
}
|
||||
|
||||
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
IAsyncResult result = sock.BeginConnect(new DnsEndPoint("localhost", port), null, null);
|
||||
sock.EndConnect(result);
|
||||
|
||||
sock.Dispose();
|
||||
server.Dispose();
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Theory]
|
||||
[InlineData(SocketImplementationType.APM)]
|
||||
[InlineData(SocketImplementationType.Async)]
|
||||
public void Socket_BeginConnectDnsEndPoint_SetSocketProperties_Success(SocketImplementationType type)
|
||||
{
|
||||
int port;
|
||||
using (SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port))
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
sock.LingerState = new LingerOption(false, 0);
|
||||
sock.NoDelay = true;
|
||||
sock.ReceiveBufferSize = 1024;
|
||||
sock.ReceiveTimeout = 100;
|
||||
sock.SendBufferSize = 1024;
|
||||
sock.SendTimeout = 100;
|
||||
IAsyncResult result = sock.BeginConnect(new DnsEndPoint("localhost", port), null, null);
|
||||
sock.EndConnect(result);
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void Socket_BeginConnectDnsEndPoint_Failure()
|
||||
{
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
@@ -162,41 +196,71 @@ namespace System.Net.Sockets.Tests
|
||||
[InlineData(SocketImplementationType.APM)]
|
||||
[InlineData(SocketImplementationType.Async)]
|
||||
[Trait("IPv4", "true")]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void Socket_ConnectAsyncDnsEndPoint_Success(SocketImplementationType type)
|
||||
{
|
||||
Assert.True(Capability.IPv4Support());
|
||||
|
||||
int port;
|
||||
SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port);
|
||||
|
||||
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
|
||||
args.RemoteEndPoint = new DnsEndPoint("localhost", port);
|
||||
args.Completed += OnConnectAsyncCompleted;
|
||||
|
||||
ManualResetEvent complete = new ManualResetEvent(false);
|
||||
args.UserToken = complete;
|
||||
|
||||
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
bool willRaiseEvent = sock.ConnectAsync(args);
|
||||
if (willRaiseEvent)
|
||||
using (SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port))
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (ManualResetEvent complete = new ManualResetEvent(false))
|
||||
{
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
|
||||
args.RemoteEndPoint = new DnsEndPoint("localhost", port);
|
||||
args.Completed += OnConnectAsyncCompleted;
|
||||
args.UserToken = complete;
|
||||
|
||||
bool willRaiseEvent = sock.ConnectAsync(args);
|
||||
if (willRaiseEvent)
|
||||
{
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
Assert.Null(args.ConnectByNameError);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
Assert.Null(args.ConnectByNameError);
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Theory]
|
||||
[InlineData(SocketImplementationType.APM)]
|
||||
[InlineData(SocketImplementationType.Async)]
|
||||
[Trait("IPv4", "true")]
|
||||
public void Socket_ConnectAsyncDnsEndPoint_SetSocketProperties_Success(SocketImplementationType type)
|
||||
{
|
||||
Assert.True(Capability.IPv4Support());
|
||||
|
||||
complete.Dispose();
|
||||
sock.Dispose();
|
||||
server.Dispose();
|
||||
int port;
|
||||
using (SocketTestServer server = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port))
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (ManualResetEvent complete = new ManualResetEvent(false))
|
||||
{
|
||||
sock.LingerState = new LingerOption(false, 0);
|
||||
sock.NoDelay = true;
|
||||
sock.ReceiveBufferSize = 1024;
|
||||
sock.ReceiveTimeout = 100;
|
||||
sock.SendBufferSize = 1024;
|
||||
sock.SendTimeout = 100;
|
||||
|
||||
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
|
||||
args.RemoteEndPoint = new DnsEndPoint("localhost", port);
|
||||
args.Completed += OnConnectAsyncCompleted;
|
||||
args.UserToken = complete;
|
||||
|
||||
bool willRaiseEvent = sock.ConnectAsync(args);
|
||||
if (willRaiseEvent)
|
||||
{
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
Assert.Null(args.ConnectByNameError);
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[Trait("IPv4", "true")]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void Socket_ConnectAsyncDnsEndPoint_HostNotFound()
|
||||
{
|
||||
Assert.True(Capability.IPv4Support());
|
||||
@@ -205,27 +269,23 @@ namespace System.Net.Sockets.Tests
|
||||
args.RemoteEndPoint = new DnsEndPoint("notahostname.invalid.corp.microsoft.com", UnusedPort);
|
||||
args.Completed += OnConnectAsyncCompleted;
|
||||
|
||||
ManualResetEvent complete = new ManualResetEvent(false);
|
||||
args.UserToken = complete;
|
||||
|
||||
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
bool willRaiseEvent = sock.ConnectAsync(args);
|
||||
if (willRaiseEvent)
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (ManualResetEvent complete = new ManualResetEvent(false))
|
||||
{
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
args.UserToken = complete;
|
||||
bool willRaiseEvent = sock.ConnectAsync(args);
|
||||
if (willRaiseEvent)
|
||||
{
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
}
|
||||
|
||||
AssertHostNotFoundOrNoData(args);
|
||||
}
|
||||
|
||||
AssertHostNotFoundOrNoData(args);
|
||||
|
||||
complete.Dispose();
|
||||
sock.Dispose();
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[Trait("IPv4", "true")]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void Socket_ConnectAsyncDnsEndPoint_ConnectionRefused()
|
||||
{
|
||||
Assert.True(Capability.IPv4Support());
|
||||
@@ -234,23 +294,21 @@ namespace System.Net.Sockets.Tests
|
||||
args.RemoteEndPoint = new DnsEndPoint("localhost", UnusedPort);
|
||||
args.Completed += OnConnectAsyncCompleted;
|
||||
|
||||
ManualResetEvent complete = new ManualResetEvent(false);
|
||||
args.UserToken = complete;
|
||||
|
||||
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
bool willRaiseEvent = sock.ConnectAsync(args);
|
||||
if (willRaiseEvent)
|
||||
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (ManualResetEvent complete = new ManualResetEvent(false))
|
||||
{
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
args.UserToken = complete;
|
||||
|
||||
bool willRaiseEvent = sock.ConnectAsync(args);
|
||||
if (willRaiseEvent)
|
||||
{
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.ConnectionRefused, args.SocketError);
|
||||
Assert.True(args.ConnectByNameError is SocketException);
|
||||
Assert.Equal(SocketError.ConnectionRefused, ((SocketException)args.ConnectByNameError).SocketErrorCode);
|
||||
}
|
||||
|
||||
Assert.Equal(SocketError.ConnectionRefused, args.SocketError);
|
||||
Assert.True(args.ConnectByNameError is SocketException);
|
||||
Assert.Equal(SocketError.ConnectionRefused, ((SocketException)args.ConnectByNameError).SocketErrorCode);
|
||||
|
||||
complete.Dispose();
|
||||
sock.Dispose();
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
@@ -265,45 +323,43 @@ namespace System.Net.Sockets.Tests
|
||||
Assert.True(Capability.IPv4Support() && Capability.IPv6Support());
|
||||
|
||||
int port4, port6;
|
||||
SocketTestServer server4 = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port4);
|
||||
SocketTestServer server6 = SocketTestServer.SocketTestServerFactory(type, IPAddress.IPv6Loopback, out port6);
|
||||
using (SocketTestServer server4 = SocketTestServer.SocketTestServerFactory(type, IPAddress.Loopback, out port4))
|
||||
using (SocketTestServer server6 = SocketTestServer.SocketTestServerFactory(type, IPAddress.IPv6Loopback, out port6))
|
||||
{
|
||||
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
|
||||
args.RemoteEndPoint = new DnsEndPoint("localhost", port4);
|
||||
args.Completed += OnConnectAsyncCompleted;
|
||||
|
||||
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
|
||||
args.RemoteEndPoint = new DnsEndPoint("localhost", port4);
|
||||
args.Completed += OnConnectAsyncCompleted;
|
||||
ManualResetEvent complete = new ManualResetEvent(false);
|
||||
args.UserToken = complete;
|
||||
|
||||
ManualResetEvent complete = new ManualResetEvent(false);
|
||||
args.UserToken = complete;
|
||||
Assert.True(Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args));
|
||||
|
||||
Assert.True(Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args));
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
Assert.Null(args.ConnectByNameError);
|
||||
Assert.NotNull(args.ConnectSocket);
|
||||
Assert.True(args.ConnectSocket.AddressFamily == AddressFamily.InterNetwork);
|
||||
Assert.True(args.ConnectSocket.Connected);
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
Assert.Null(args.ConnectByNameError);
|
||||
Assert.NotNull(args.ConnectSocket);
|
||||
Assert.True(args.ConnectSocket.AddressFamily == AddressFamily.InterNetwork);
|
||||
Assert.True(args.ConnectSocket.Connected);
|
||||
args.ConnectSocket.Dispose();
|
||||
|
||||
args.ConnectSocket.Dispose();
|
||||
args.RemoteEndPoint = new DnsEndPoint("localhost", port6);
|
||||
complete.Reset();
|
||||
|
||||
args.RemoteEndPoint = new DnsEndPoint("localhost", port6);
|
||||
complete.Reset();
|
||||
Assert.True(Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args));
|
||||
|
||||
Assert.True(Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args));
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
|
||||
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
Assert.Null(args.ConnectByNameError);
|
||||
Assert.NotNull(args.ConnectSocket);
|
||||
Assert.True(args.ConnectSocket.AddressFamily == AddressFamily.InterNetworkV6);
|
||||
Assert.True(args.ConnectSocket.Connected);
|
||||
|
||||
Assert.Equal(SocketError.Success, args.SocketError);
|
||||
Assert.Null(args.ConnectByNameError);
|
||||
Assert.NotNull(args.ConnectSocket);
|
||||
Assert.True(args.ConnectSocket.AddressFamily == AddressFamily.InterNetworkV6);
|
||||
Assert.True(args.ConnectSocket.Connected);
|
||||
|
||||
args.ConnectSocket.Dispose();
|
||||
|
||||
server4.Dispose();
|
||||
server6.Dispose();
|
||||
args.ConnectSocket.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
@@ -392,21 +448,5 @@ namespace System.Net.Sockets.Tests
|
||||
Assert.True((errorCode == SocketError.HostNotFound) || (errorCode == SocketError.NoData),
|
||||
"SocketError: " + errorCode);
|
||||
}
|
||||
|
||||
#region GC Finalizer test
|
||||
// This test assumes sequential execution of tests and that it is going to be executed after other tests
|
||||
// that used Sockets.
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
public void TestFinalizers()
|
||||
{
|
||||
// Making several passes through the FReachable list.
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
0e069ad23d843bacbda6500a150dc1333799deaf
|
||||
9bcf3aab3ce51fc0be42dbdaab18dd936eff7a9e
|
@@ -2,12 +2,11 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Xunit;
|
||||
|
||||
namespace System.Net.Sockets.Tests
|
||||
{
|
||||
public class HandleTests
|
||||
public class HandleTest
|
||||
{
|
||||
[Fact]
|
||||
public static void ValidHandle_NotNegativeOne()
|
||||
@@ -19,7 +18,6 @@ namespace System.Net.Sockets.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public static void ValidHandle_NotZero()
|
||||
{
|
||||
using (var s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
|
@@ -2,10 +2,6 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
using Xunit;
|
||||
@@ -41,6 +37,8 @@ namespace System.Net.Sockets.Tests
|
||||
Assert.NotEqual(packetInfo, default(IPPacketInformation));
|
||||
Assert.False(packetInfo == default(IPPacketInformation));
|
||||
Assert.True(packetInfo != default(IPPacketInformation));
|
||||
|
||||
int ignored = packetInfo.Interface; // just make sure it doesn't throw, nothing else to verify
|
||||
}
|
||||
|
||||
[ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/Microsoft/BashOnWindows/issues/987
|
||||
|
@@ -44,7 +44,7 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[PlatformSpecific(~TestPlatforms.OSX)]
|
||||
[PlatformSpecific(~TestPlatforms.OSX)] // The upper bound for linger time is drastically different on OS X.
|
||||
public void Socket_LingerState_Upper_Boundaries_CorrectBehavior()
|
||||
{
|
||||
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
@@ -56,7 +56,7 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.OSX)]
|
||||
[PlatformSpecific(TestPlatforms.OSX)] // The upper bound for linger time is drastically different on OS X.
|
||||
public void Socket_LingerState_Upper_Boundaries_CorrectBehavior_OSX()
|
||||
{
|
||||
// The upper bound for linger time is drastically different on OS X.
|
||||
|
@@ -6,12 +6,14 @@ using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Tracing;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace System.Net.Sockets.Tests
|
||||
{
|
||||
public class LoggingTest : RemoteExecutorTestBase
|
||||
{
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "NetEventSource is only part of .NET Core")]
|
||||
public static void EventSource_ExistsWithCorrectId()
|
||||
{
|
||||
Type esType = typeof(Socket).Assembly.GetType("System.Net.NetEventSource", throwOnError: true, ignoreCase: false);
|
||||
@@ -25,6 +27,7 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
[OuterLoop]
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "NetEventSource is only part of .NET Core")]
|
||||
public void EventSource_EventsRaisedAsExpected()
|
||||
{
|
||||
RemoteInvoke(() =>
|
||||
@@ -34,8 +37,22 @@ namespace System.Net.Sockets.Tests
|
||||
var events = new ConcurrentQueue<EventWrittenEventArgs>();
|
||||
listener.RunWithCallback(events.Enqueue, () =>
|
||||
{
|
||||
// Invoke a test that'll cause some events to be generated
|
||||
// Invoke several tests to execute code paths while tracing is enabled
|
||||
|
||||
new SendReceiveSync(new NullTestOutputHelper()).SendRecv_Stream_TCP(IPAddress.Loopback, false).GetAwaiter();
|
||||
new SendReceiveSync(new NullTestOutputHelper()).SendRecv_Stream_TCP(IPAddress.Loopback, true).GetAwaiter();
|
||||
|
||||
new SendReceiveTask(new NullTestOutputHelper()).SendRecv_Stream_TCP(IPAddress.Loopback, false).GetAwaiter();
|
||||
new SendReceiveTask(new NullTestOutputHelper()).SendRecv_Stream_TCP(IPAddress.Loopback, true).GetAwaiter();
|
||||
|
||||
new SendReceiveEap(new NullTestOutputHelper()).SendRecv_Stream_TCP(IPAddress.Loopback, false).GetAwaiter();
|
||||
new SendReceiveEap(new NullTestOutputHelper()).SendRecv_Stream_TCP(IPAddress.Loopback, true).GetAwaiter();
|
||||
|
||||
new SendReceiveApm(new NullTestOutputHelper()).SendRecv_Stream_TCP(IPAddress.Loopback, false).GetAwaiter();
|
||||
new SendReceiveApm(new NullTestOutputHelper()).SendRecv_Stream_TCP(IPAddress.Loopback, true).GetAwaiter();
|
||||
|
||||
new NetworkStreamTest().CopyToAsync_AllDataCopied(4096).GetAwaiter().GetResult();
|
||||
new NetworkStreamTest().Timeout_ValidData_Roundtrips().GetAwaiter().GetResult();
|
||||
});
|
||||
Assert.DoesNotContain(events, ev => ev.EventId == 0); // errors from the EventSource itself
|
||||
Assert.InRange(events.Count, 1, int.MaxValue);
|
||||
@@ -43,5 +60,11 @@ namespace System.Net.Sockets.Tests
|
||||
return SuccessExitCode;
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
private sealed class NullTestOutputHelper : ITestOutputHelper
|
||||
{
|
||||
public void WriteLine(string message) { }
|
||||
public void WriteLine(string format, params object[] args) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
106
external/corefx/src/System.Net.Sockets/tests/FunctionalTests/MulticastOptionTest.cs
vendored
Normal file
106
external/corefx/src/System.Net.Sockets/tests/FunctionalTests/MulticastOptionTest.cs
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace System.Net.Sockets.Tests
|
||||
{
|
||||
public class MulticastOptionTest
|
||||
{
|
||||
[Fact]
|
||||
public void MulticastOption_Ctor_InvalidArguments_Throws()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("group", () => new MulticastOption(null));
|
||||
Assert.Throws<ArgumentNullException>("group", () => new MulticastOption(null, 0));
|
||||
Assert.Throws<ArgumentNullException>("group", () => new MulticastOption(null, null));
|
||||
Assert.Throws<ArgumentNullException>("mcint", () => new MulticastOption(IPAddress.Loopback, null));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("interfaceIndex", () => new MulticastOption(IPAddress.Loopback, -1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("interfaceIndex", () => new MulticastOption(IPAddress.Loopback, int.MaxValue));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MulticastOption_Group_Roundtrips()
|
||||
{
|
||||
var option = new MulticastOption(IPAddress.Any);
|
||||
Assert.Same(IPAddress.Any, option.Group);
|
||||
|
||||
option.Group = null;
|
||||
Assert.Null(option.Group);
|
||||
|
||||
option.Group = IPAddress.Broadcast;
|
||||
Assert.Same(IPAddress.Broadcast, option.Group);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MulticastOption_InterfaceIndex_Roundtrips()
|
||||
{
|
||||
var option = new MulticastOption(IPAddress.Any);
|
||||
Assert.Equal(0, option.InterfaceIndex);
|
||||
|
||||
option = new MulticastOption(IPAddress.Any, 42);
|
||||
Assert.Equal(42, option.InterfaceIndex);
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>("value", () => option.InterfaceIndex = -1);
|
||||
Assert.Throws<ArgumentOutOfRangeException>("value", () => option.InterfaceIndex = int.MaxValue);
|
||||
|
||||
option.InterfaceIndex = 1;
|
||||
Assert.Equal(1, option.InterfaceIndex);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MulticastOption_LocalAddress_Roundtrips()
|
||||
{
|
||||
var options = new MulticastOption(IPAddress.Any);
|
||||
Assert.Same(IPAddress.Any, options.LocalAddress);
|
||||
|
||||
options = new MulticastOption(IPAddress.Loopback, 42);
|
||||
Assert.Equal(42, options.InterfaceIndex);
|
||||
Assert.Null(options.LocalAddress);
|
||||
|
||||
options.LocalAddress = IPAddress.Broadcast;
|
||||
Assert.Equal(0, options.InterfaceIndex);
|
||||
Assert.Same(IPAddress.Broadcast, options.LocalAddress);
|
||||
|
||||
options = new MulticastOption(IPAddress.Loopback, IPAddress.Any);
|
||||
Assert.Same(IPAddress.Any, options.LocalAddress);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IPv6MulticastOption_Ctor_InvalidArguments_Throws()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("group", () => new IPv6MulticastOption(null));
|
||||
Assert.Throws<ArgumentNullException>("group", () => new IPv6MulticastOption(null, 0));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("ifindex", () => new IPv6MulticastOption(IPAddress.Loopback, -1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("ifindex", () => new IPv6MulticastOption(IPAddress.Loopback, long.MaxValue));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IPv6MulticastOption_Group_Roundtrips()
|
||||
{
|
||||
var option = new IPv6MulticastOption(IPAddress.Any);
|
||||
Assert.Same(IPAddress.Any, option.Group);
|
||||
|
||||
Assert.Throws<ArgumentNullException>("value", () => option.Group = null);
|
||||
|
||||
option.Group = IPAddress.Broadcast;
|
||||
Assert.Same(IPAddress.Broadcast, option.Group);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IPv6MulticastOption_InterfaceIndex_Roundtrips()
|
||||
{
|
||||
var option = new IPv6MulticastOption(IPAddress.Any);
|
||||
Assert.Equal(0, option.InterfaceIndex);
|
||||
|
||||
option = new IPv6MulticastOption(IPAddress.Any, 42);
|
||||
Assert.Equal(42, option.InterfaceIndex);
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>("value", () => option.InterfaceIndex = -1);
|
||||
Assert.Throws<ArgumentOutOfRangeException>("value", () => option.InterfaceIndex = long.MaxValue);
|
||||
|
||||
option.InterfaceIndex = 1;
|
||||
Assert.Equal(1, option.InterfaceIndex);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
61
external/corefx/src/System.Net.Sockets/tests/FunctionalTests/OSSupport.cs
vendored
Normal file
61
external/corefx/src/System.Net.Sockets/tests/FunctionalTests/OSSupport.cs
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace System.Net.Sockets.Tests
|
||||
{
|
||||
public class OSSupportTest
|
||||
{
|
||||
[Fact]
|
||||
public void SupportsIPv4_MatchesOSSupportsIPv4()
|
||||
{
|
||||
#pragma warning disable 0618 // Supports* are obsoleted
|
||||
Assert.Equal(Socket.SupportsIPv4, Socket.OSSupportsIPv4);
|
||||
#pragma warning restore
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SupportsIPv6_MatchesOSSupportsIPv6()
|
||||
{
|
||||
#pragma warning disable 0618 // Supports* are obsoleted
|
||||
Assert.Equal(Socket.SupportsIPv6, Socket.OSSupportsIPv6);
|
||||
#pragma warning restore
|
||||
}
|
||||
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
[Fact]
|
||||
public void UseOnlyOverlappedIO_AlwaysFalse()
|
||||
{
|
||||
using (var s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
Assert.Equal(AddressFamily.InterNetwork, s.AddressFamily);
|
||||
Assert.Equal(SocketType.Stream, s.SocketType);
|
||||
Assert.Equal(ProtocolType.Tcp, s.ProtocolType);
|
||||
|
||||
Assert.False(s.UseOnlyOverlappedIO);
|
||||
s.UseOnlyOverlappedIO = true;
|
||||
Assert.False(s.UseOnlyOverlappedIO);
|
||||
}
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // Windows IOCTL
|
||||
[Fact]
|
||||
public void IOControl_FIONREAD_Success()
|
||||
{
|
||||
using (var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
byte[] outValue = new byte[sizeof(int)];
|
||||
|
||||
const int FIONREAD = 0x4004667F;
|
||||
Assert.Equal(4, client.IOControl(FIONREAD, null, outValue));
|
||||
Assert.Equal(client.Available, BitConverter.ToInt32(outValue, 0));
|
||||
|
||||
Assert.Equal(4, client.IOControl(IOControlCode.DataToRead, null, outValue));
|
||||
Assert.Equal(client.Available, BitConverter.ToInt32(outValue, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,6 +2,8 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Xunit;
|
||||
|
||||
namespace System.Net.Sockets.Tests
|
||||
@@ -77,74 +79,128 @@ namespace System.Net.Sockets.Tests
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/Microsoft/BashOnWindows/issues/987
|
||||
public void Success_APM()
|
||||
[ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/Microsoft/BashOnWindows/issues/987
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public void Success_APM(bool ipv4)
|
||||
{
|
||||
if (Socket.OSSupportsIPv4)
|
||||
AddressFamily family;
|
||||
IPAddress loopback, any;
|
||||
SocketOptionLevel level;
|
||||
if (ipv4)
|
||||
{
|
||||
using (Socket receiver = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
|
||||
if (!Socket.OSSupportsIPv4) return;
|
||||
family = AddressFamily.InterNetwork;
|
||||
loopback = IPAddress.Loopback;
|
||||
any = IPAddress.Any;
|
||||
level = SocketOptionLevel.IP;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Socket.OSSupportsIPv6) return;
|
||||
family = AddressFamily.InterNetworkV6;
|
||||
loopback = IPAddress.IPv6Loopback;
|
||||
any = IPAddress.IPv6Any;
|
||||
level = SocketOptionLevel.IPv6;
|
||||
}
|
||||
|
||||
using (var receiver = new Socket(family, SocketType.Dgram, ProtocolType.Udp))
|
||||
using (var sender = new Socket(family, SocketType.Dgram, ProtocolType.Udp))
|
||||
{
|
||||
int port = receiver.BindToAnonymousPort(loopback);
|
||||
receiver.SetSocketOption(level, SocketOptionName.PacketInformation, true);
|
||||
sender.Bind(new IPEndPoint(loopback, 0));
|
||||
|
||||
for (int i = 0; i < TestSettings.UDPRedundancy; i++)
|
||||
{
|
||||
int port = receiver.BindToAnonymousPort(IPAddress.Loopback);
|
||||
receiver.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.PacketInformation, true);
|
||||
|
||||
Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
sender.Bind(new IPEndPoint(IPAddress.Loopback, 0));
|
||||
|
||||
for (int i = 0; i < TestSettings.UDPRedundancy; i++)
|
||||
{
|
||||
sender.SendTo(new byte[1024], new IPEndPoint(IPAddress.Loopback, port));
|
||||
}
|
||||
|
||||
IPPacketInformation packetInformation;
|
||||
SocketFlags flags = SocketFlags.None;
|
||||
EndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0);
|
||||
|
||||
IAsyncResult ar = receiver.BeginReceiveMessageFrom(new byte[1024], 0, 1024, flags, ref remoteEP, null, null);
|
||||
ar.AsyncWaitHandle.WaitOne();
|
||||
int len = receiver.EndReceiveMessageFrom(ar, ref flags, ref remoteEP, out packetInformation);
|
||||
|
||||
Assert.Equal(1024, len);
|
||||
Assert.Equal(sender.LocalEndPoint, remoteEP);
|
||||
Assert.Equal(((IPEndPoint)sender.LocalEndPoint).Address, packetInformation.Address);
|
||||
|
||||
sender.Dispose();
|
||||
sender.SendTo(new byte[1024], new IPEndPoint(loopback, port));
|
||||
}
|
||||
|
||||
IPPacketInformation packetInformation;
|
||||
SocketFlags flags = SocketFlags.None;
|
||||
EndPoint remoteEP = new IPEndPoint(any, 0);
|
||||
|
||||
IAsyncResult ar = receiver.BeginReceiveMessageFrom(new byte[1024], 0, 1024, flags, ref remoteEP, null, null);
|
||||
int len = receiver.EndReceiveMessageFrom(ar, ref flags, ref remoteEP, out packetInformation);
|
||||
|
||||
Assert.Equal(1024, len);
|
||||
Assert.Equal(sender.LocalEndPoint, remoteEP);
|
||||
Assert.Equal(((IPEndPoint)sender.LocalEndPoint).Address, packetInformation.Address);
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/Microsoft/BashOnWindows/issues/987
|
||||
public void Success_APM_IPv6()
|
||||
[ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/Microsoft/BashOnWindows/issues/987
|
||||
[InlineData(false, 0)]
|
||||
[InlineData(false, 1)]
|
||||
[InlineData(false, 2)]
|
||||
[InlineData(true, 0)]
|
||||
[InlineData(true, 1)]
|
||||
[InlineData(true, 2)]
|
||||
public void Success_EventArgs(bool ipv4, int bufferMode)
|
||||
{
|
||||
if (Socket.OSSupportsIPv6)
|
||||
AddressFamily family;
|
||||
IPAddress loopback, any;
|
||||
SocketOptionLevel level;
|
||||
if (ipv4)
|
||||
{
|
||||
using (Socket receiver = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp))
|
||||
if (!Socket.OSSupportsIPv4) return;
|
||||
family = AddressFamily.InterNetwork;
|
||||
loopback = IPAddress.Loopback;
|
||||
any = IPAddress.Any;
|
||||
level = SocketOptionLevel.IP;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Socket.OSSupportsIPv6) return;
|
||||
family = AddressFamily.InterNetworkV6;
|
||||
loopback = IPAddress.IPv6Loopback;
|
||||
any = IPAddress.IPv6Any;
|
||||
level = SocketOptionLevel.IPv6;
|
||||
}
|
||||
|
||||
using (var receiver = new Socket(family, SocketType.Dgram, ProtocolType.Udp))
|
||||
using (var sender = new Socket(family, SocketType.Dgram, ProtocolType.Udp))
|
||||
using (var saea = new SocketAsyncEventArgs())
|
||||
{
|
||||
int port = receiver.BindToAnonymousPort(loopback);
|
||||
receiver.SetSocketOption(level, SocketOptionName.PacketInformation, true);
|
||||
sender.Bind(new IPEndPoint(loopback, 0));
|
||||
|
||||
saea.RemoteEndPoint = new IPEndPoint(any, 0);
|
||||
switch (bufferMode)
|
||||
{
|
||||
int port = receiver.BindToAnonymousPort(IPAddress.IPv6Loopback);
|
||||
receiver.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.PacketInformation, true);
|
||||
|
||||
Socket sender = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
|
||||
sender.Bind(new IPEndPoint(IPAddress.IPv6Loopback, 0));
|
||||
|
||||
for (int i = 0; i < TestSettings.UDPRedundancy; i++)
|
||||
{
|
||||
sender.SendTo(new byte[1024], new IPEndPoint(IPAddress.IPv6Loopback, port));
|
||||
}
|
||||
|
||||
IPPacketInformation packetInformation;
|
||||
SocketFlags flags = SocketFlags.None;
|
||||
EndPoint remoteEP = new IPEndPoint(IPAddress.IPv6Any, 0);
|
||||
|
||||
IAsyncResult ar = receiver.BeginReceiveMessageFrom(new byte[1024], 0, 1024, flags, ref remoteEP, null, null);
|
||||
ar.AsyncWaitHandle.WaitOne();
|
||||
int len = receiver.EndReceiveMessageFrom(ar, ref flags, ref remoteEP, out packetInformation);
|
||||
|
||||
Assert.Equal(1024, len);
|
||||
Assert.Equal(sender.LocalEndPoint, remoteEP);
|
||||
Assert.Equal(((IPEndPoint)sender.LocalEndPoint).Address, packetInformation.Address);
|
||||
|
||||
sender.Dispose();
|
||||
case 0: // single buffer
|
||||
saea.SetBuffer(new byte[1024], 0, 1024);
|
||||
break;
|
||||
case 1: // single buffer in buffer list
|
||||
saea.BufferList = new List<ArraySegment<byte>>
|
||||
{
|
||||
new ArraySegment<byte>(new byte[1024])
|
||||
};
|
||||
break;
|
||||
case 2: // multiple buffers in buffer list
|
||||
saea.BufferList = new List<ArraySegment<byte>>
|
||||
{
|
||||
new ArraySegment<byte>(new byte[512]),
|
||||
new ArraySegment<byte>(new byte[512])
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
var mres = new ManualResetEventSlim();
|
||||
saea.Completed += delegate { mres.Set(); };
|
||||
|
||||
bool pending = receiver.ReceiveMessageFromAsync(saea);
|
||||
for (int i = 0; i < TestSettings.UDPRedundancy; i++)
|
||||
{
|
||||
sender.SendTo(new byte[1024], new IPEndPoint(loopback, port));
|
||||
}
|
||||
if (pending) Assert.True(mres.Wait(30000), "Expected operation to complete within timeout");
|
||||
|
||||
Assert.Equal(1024, saea.BytesTransferred);
|
||||
Assert.Equal(sender.LocalEndPoint, saea.RemoteEndPoint);
|
||||
Assert.Equal(((IPEndPoint)sender.LocalEndPoint).Address, saea.ReceiveMessageFromPacketInfo.Address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,8 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Net.Test.Common;
|
||||
using System.Threading;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace System.Net.Sockets.Tests
|
||||
@@ -19,7 +18,7 @@ namespace System.Net.Sockets.Tests
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/Microsoft/BashOnWindows/issues/987
|
||||
public void Success()
|
||||
public void Success_IPv4()
|
||||
{
|
||||
ManualResetEvent completed = new ManualResetEvent(false);
|
||||
|
||||
@@ -104,5 +103,36 @@ namespace System.Net.Sockets.Tests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[OuterLoop] // TODO: Issue #11345
|
||||
[ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/Microsoft/BashOnWindows/issues/987
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public async Task Task_Success(bool ipv4)
|
||||
{
|
||||
AddressFamily family = ipv4 ? AddressFamily.InterNetwork : AddressFamily.InterNetworkV6;
|
||||
IPAddress loopback = ipv4 ? IPAddress.Loopback : IPAddress.IPv6Loopback;
|
||||
|
||||
using (Socket receiver = new Socket(family, SocketType.Dgram, ProtocolType.Udp))
|
||||
using (Socket sender = new Socket(family, SocketType.Dgram, ProtocolType.Udp))
|
||||
{
|
||||
int port = receiver.BindToAnonymousPort(loopback);
|
||||
receiver.SetSocketOption(ipv4 ? SocketOptionLevel.IP : SocketOptionLevel.IPv6, SocketOptionName.PacketInformation, true);
|
||||
|
||||
sender.Bind(new IPEndPoint(loopback, 0));
|
||||
|
||||
for (int i = 0; i < TestSettings.UDPRedundancy; i++)
|
||||
{
|
||||
sender.SendTo(new byte[1024], new IPEndPoint(loopback, port));
|
||||
}
|
||||
|
||||
SocketReceiveMessageFromResult result = await receiver.ReceiveMessageFromAsync(
|
||||
new ArraySegment<byte>(new byte[1024], 0, 1024), SocketFlags.None,
|
||||
new IPEndPoint(ipv4 ? IPAddress.Any : IPAddress.IPv6Any, 0));
|
||||
Assert.Equal(1024, result.ReceivedBytes);
|
||||
Assert.Equal(sender.LocalEndPoint, result.RemoteEndPoint);
|
||||
Assert.Equal(((IPEndPoint)sender.LocalEndPoint).Address, result.PacketInformation.Address);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,13 +4,9 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Test.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace System.Net.Sockets.Tests
|
||||
{
|
||||
|
@@ -52,7 +52,7 @@ namespace System.Net.Sockets.Tests
|
||||
var readList = new List<Socket>(readPairs.Select(p => p.Key).ToArray());
|
||||
var writeList = new List<Socket>(writePairs.Select(p => p.Key).ToArray());
|
||||
|
||||
Socket.Select(readList, writeList, null, FailTimeoutMicroseconds);
|
||||
Socket.Select(readList, writeList, null, -1); // using -1 to test wait code path, but should complete instantly
|
||||
|
||||
// Since no buffers are full, all writes should be available.
|
||||
Assert.Equal(writePairs.Length, writeList.Count);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user