dotnet/runtime

Inconsistent behavior of Dgram Socket.Disconnect

Open

#34,473 建立於 2020年4月2日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)C# (5,445 fork)batch import
area-System.Net.Socketsenhancementhelp wantedtenet-compatibility

倉庫指標

Star
 (17,886 star)
PR 合併指標
 (平均合併 12天 11小時) (30 天內合併 661 個 PR)

描述

Socket.Disconnect(boolean) method called on UDP socket behaves differently on different platforms. On Linux (Ubuntu 18.04.03 LTS) x64 it doesn't throw exception. On Windows 10 I get the following exception:

Message: 
    System.Net.Sockets.SocketException : A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
  Stack Trace: 
    Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
    Socket.Disconnect(Boolean reuseSocket)

Probably, behavior on Windows 10 is correct because UDP is connectionless protocol.

Version is .NET Core 3.1.201.

貢獻者指南