Consider the following test case from #47229:
[Theory]
[InlineData(SocketShutdown.Receive)] // Works
[InlineData(SocketShutdown.Both)] // Sporadic failures
public async Task ShutdownReceiveBeforeOperation_ThrowsSocketException(SocketShutdown shutdown)
{
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.BindToAnonymousPort(IPAddress.Any);
socket.Shutdown(shutdown);
SocketException exception = await Assert.ThrowsAnyAsync<SocketException>(() => ReceiveMessageFromAsync(socket, new byte[1], GetGetDummyTestEndpoint()))
.TimeoutAfter(CancellationTestTimeout);
Assert.Equal(SocketError.Shutdown, exception.SocketErrorCode);
}
The SocketShutdown.Both case seems to lead to intermittent timeouts on CI:
https://dev.azure.com/dnceng/public/_build/results?buildId=964879&view=ms.vss-test-web.build-test-results-tab&runId=30372566&resultId=161868&paneView=debug
Shutting down of UDP sockets is a very unusual thing to do, that doesn't even work on Unix, so we may end up closing this as wontfix, but I want to make sure the issue is documented and discussed. Also note that we do not have equivalent tests for the interaction between Shutdown and TCP Receive, so we may want to investigate if it's a more general problem not specific to UDP.