Skip to content
Merged
Show file tree
Hide file tree
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 @@ -70,7 +70,7 @@ public partial class Socket : IDisposable
private bool _disposed;

public Socket(SocketType socketType, ProtocolType protocolType)
: this(OSSupportsIPv6DualMode ? AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork, socketType, protocolType)
: this(OSSupportsIPv6 ? AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork, socketType, protocolType)
{
if (OSSupportsIPv6DualMode)
{
Expand Down Expand Up @@ -749,7 +749,7 @@ public bool DualMode
{
return false;
}
if (!OSSupportsIPv6DualMode)
if (OperatingSystem.IsWasi())
{
return false;
}
Expand All @@ -762,7 +762,7 @@ public bool DualMode
throw new NotSupportedException(SR.net_invalidversion);
}

if (!OSSupportsIPv6DualMode && value) throw new PlatformNotSupportedException();
if (OperatingSystem.IsWasi() && value) throw new PlatformNotSupportedException();

SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, value ? 0 : 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public async Task DisableIPv6_OSSupportsIPv6_False()
static void RunTest()
{
Assert.False(Socket.OSSupportsIPv6);

// related to https://github.com/dotnet/runtime/issues/122435
var listenSocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
listenSocket.DualMode = true;

listenSocket.Bind(new IPEndPoint(IPAddress.IPv6Any, 0));
listenSocket.Listen(1);
listenSocket.Close();
}
}

Expand Down
Loading