Incorrect usage of LingerTime can cause System.Net.Sockets tests failure
After investigating into dotnet/runtime#21547, there is a risk by using LingerState to wait for send/receive operation complete, before dispose the socket.
Because the LingerTime value is arbitrarily set by us, some slow computers may take more time to finish the send/receive operation, so it's possible that some data are still available before we dispose the socket. And in this case, we will use a RST packet (instead of FIN) to forcibly close the connection after time out (https://github.com/dotnet/corefx/blob/master/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs#L4649, related issue dotnet/runtime#19133), and test will fail with System.Net.Sockets.SocketException, Message: An existing connection was forcibly closed by the remote host. An example is dotnet/runtime#21547
Potential fix: always use socket.Shutdown(SocketShutdown how) before we dispose() the socket.
cc: @davidsh @CIPop @stephentoub
After offline discussion, we decided to merge the issue with dotnet/runtime#21547. Any further discussion can be posted there. Thanks.