-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-System.Net.Socketsbuggood first issueIssue should be easy to implement, good for first-time contributorsIssue should be easy to implement, good for first-time contributorshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
Socket.SendFile() is not supported on Windows, but the exceptions being thrown are not consistent. The first call throws SocketException, while the second attempt leads to NotSupportedException.
Repro
The twice=true case fails:
[Theory]
[InlineData(false)]
[InlineData(true)]
public void UDP_SendFile(bool twice)
{
string tempFile = Path.GetTempFileName();
File.WriteAllBytes(tempFile, new byte[128]);
using var client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
using var listener = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
listener.BindToAnonymousPort(IPAddress.Loopback);
client.Connect(listener.LocalEndPoint);
Assert.Throws<SocketException>(() => client.SendFile(tempFile));
if (twice)
{
Assert.Throws<SocketException>(() => client.SendFile(tempFile)); // Throws NotSupportedException
}
}Edit (after discussion below)
On Linux the call does not fail. We should fail NotSupportedException for connectionless sockets on all OS-es in all cases.
Metadata
Metadata
Assignees
Labels
area-System.Net.Socketsbuggood first issueIssue should be easy to implement, good for first-time contributorsIssue should be easy to implement, good for first-time contributorshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors