Background and Motivation
The sync methods for Send, Receive, SendTo, and ReceiveFrom all have overloads that don't take a SocketFlags argument. This argument is rarely used.
The Task-based async methods don't have these overloads. We actually approved overloads without SocketFlags for SendTo and ReceiveFrom in #938, but these haven't been implemented yet, and it doesn't really make sense to implement them just for SendTo and ReceiveFrom.
Proposed API
Additions to existing overloads
// Existing overloads in commentspublicstaticclassSocketTaskExtensions{// public static Task<int> ReceiveAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags);publicstaticTask<int>ReceiveAsync(thisSocketsocket,ArraySegment<byte>buffer);// public static Task<int> ReceiveAsync(this Socket socket, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags);publicstaticTask<int>ReceiveAsync(thisSocketsocket,IList<ArraySegment<byte>>buffers);// public static ValueTask<int> ReceiveAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, CancellationToken cancellationToken = default(CancellationToken));publicstaticValueTask<int>ReceiveAsync(thisSocketsocket,Memory<byte>buffer,CancellationTokencancellationToken=default(CancellationToken));// public static Task<SocketReceiveFromResult> ReceiveFromAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint);publicstaticTask<SocketReceiveFromResult>ReceiveFromAsync(thisSocketsocket,ArraySegment<byte>buffer,EndPointremoteEndPoint);// public static Task<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint);publicstaticTask<SocketReceiveMessageFromResult>ReceiveMessageFromAsync(thisSocketsocket,ArraySegment<byte>buffer,EndPointremoteEndPoint);// public static Task<int> SendAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags);publicstaticTask<int>SendAsync(thisSocketsocket,ArraySegment<byte>buffer);// public static Task<int> SendAsync(this Socket socket, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags);publicstaticTask<int>SendAsync(thisSocketsocket,IList<ArraySegment<byte>>buffers);// public static ValueTask<int> SendAsync(this Socket socket, ReadOnlyMemory<byte> buffer, SocketFlags socketFlags, CancellationToken cancellationToken = default(CancellationToken));publicstaticValueTask<int>SendAsync(thisSocketsocket,ReadOnlyMemory<byte>buffer,CancellationTokencancellationToken=default(CancellationToken));// public static Task<int> SendToAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP);publicstaticTask<int>SendToAsync(thisSocketsocket,ArraySegment<byte>buffer,EndPointremoteEP);}Additions to #938
// #938 overloads in commentspublicstaticclassSocketTaskExtensions{// public static ValueTask<int> SendToAsync(this Socket socket, ReadOnlyMemory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = default);publicstaticValueTask<int>SendToAsync(thisSocketsocket,ReadOnlyMemory<byte>buffer,EndPointremoteEP,CancellationTokencancellationToken=default);// public static ValueTask<SocketReceiveFromResult> ReceiveFromAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = default);publicstaticValueTask<SocketReceiveFromResult>ReceiveFromAsync(thisSocketsocket,Memory<byte>buffer,EndPointremoteEP,CancellationTokencancellationToken=default);// public static ValueTask<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = default);publicstaticValueTask<SocketReceiveMessageFromResult>ReceiveMessageFromAsync(thisSocketsocket,Memory<byte>buffer,EndPointremoteEP,CancellationTokencancellationToken=default);}Consider: addition to #43933
This is not an async API but probably worth to add.
// #43933 overload in commentspublicclassSocket{// public int ReceiveMessageFrom(Span<byte> buffer, ref SocketFlags socketFlags, ref EndPoint remoteEP, out IPPacketInformation ipPacketInformation);publicintReceiveMessageFrom(Span<byte>buffer,refEndPointremoteEP,outIPPacketInformationipPacketInformation);}@scalablecory@wfurt@antonfirsov@stephentoub Thoughts?
Background and Motivation
The sync methods for Send, Receive, SendTo, and ReceiveFrom all have overloads that don't take a SocketFlags argument. This argument is rarely used.
The Task-based async methods don't have these overloads. We actually approved overloads without SocketFlags for SendTo and ReceiveFrom in #938, but these haven't been implemented yet, and it doesn't really make sense to implement them just for SendTo and ReceiveFrom.
Proposed API
Additions to existing overloads
Additions to #938
Consider: addition to #43933
This is not an async API but probably worth to add.
@scalablecory@wfurt@antonfirsov@stephentoub Thoughts?