Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1129,27 +1129,12 @@ public void Connect_Parallel_Success()
[SkipOnPlatform(TestPlatforms.Wasi, "Wasi doesn't support DualMode")]
public void Connect_Parallel_Fails()
{
using PortBlocker portBlocker = new PortBlocker(() =>
{
Socket socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
socket.DualMode = false;
socket.BindToAnonymousPort(IPAddress.IPv6Loopback);
return socket;
});
Socket a = portBlocker.MainSocket;
// the port blocker did not call Socket.Bind so we called bind() but we did not update properties on Socket
Socket b = new Socket(portBlocker.SecondarySocket.SafeHandle);

// do NOT a.Listen(1);
// do NOT b.Listen(1);
// Do NOT a.AcceptAsync();
// Do NOT b.AcceptAsync();

var mres = new ManualResetEventSlim();
SocketAsyncEventArgs saea = new SocketAsyncEventArgs();
saea.RemoteEndPoint = new DnsEndPoint("localhost", portBlocker.Port);
// A bound but non-listening port can time out instead of refusing connections on macOS.
saea.RemoteEndPoint = new DnsEndPoint("localhost", DualModeBase.UnusedPort);
saea.Completed += (_, _) => mres.Set();
Comment thread
MihaZupan marked this conversation as resolved.
if (Socket.ConnectAsync(a.SocketType, a.ProtocolType, saea, ConnectAlgorithm.Parallel))
if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, saea, ConnectAlgorithm.Parallel))
{
Assert.True(mres.Wait(TestSettings.PassingTestLongTimeout), "Completed did not get called in time");
}
Expand Down
Loading