Muokkaa

Jaa


SendFile throws NotSupportedException for connectionless sockets

The behavior of the SendFile method family for connectionless (for example, UDP) sockets is now consistent across all platforms. The affected methods now throw a NotSupportedException on all platforms.

Previous behavior

Previously, for a connectionless Socket (for example, UDP), the following behaviors were observed:

New behavior

Starting in .NET 8, for a connectionless Socket (for example, UDP), the following behaviors are observed:

Version introduced

.NET 8 RC 1

Type of breaking change

This change is a behavioral change.

Reason for change

Given that SendFile is typically used with large amounts of data, it doesn't make sense to use it with connectionless sockets. In addition, the previous behavior was inconsistent, throwing SocketException on some platforms, while succeeding on others with an unpredictable outcome.

Do not use SendFile methods for connectionless sockets.

Affected APIs