-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Net.Socketshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
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 comments
public static class SocketTaskExtensions
{
// public static Task<int> ReceiveAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags);
public static Task<int> ReceiveAsync(this Socket socket, ArraySegment<byte> buffer);
// public static Task<int> ReceiveAsync(this Socket socket, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags);
public static Task<int> ReceiveAsync(this Socket socket, IList<ArraySegment<byte>> buffers);
// public static ValueTask<int> ReceiveAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, CancellationToken cancellationToken = default(CancellationToken));
public static ValueTask<int> ReceiveAsync(this Socket socket, Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken));
// public static Task<SocketReceiveFromResult> ReceiveFromAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint);
public static Task<SocketReceiveFromResult> ReceiveFromAsync(this Socket socket, ArraySegment<byte> buffer, EndPoint remoteEndPoint);
// public static Task<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint);
public static Task<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this Socket socket, ArraySegment<byte> buffer, EndPoint remoteEndPoint);
// public static Task<int> SendAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags);
public static Task<int> SendAsync(this Socket socket, ArraySegment<byte> buffer);
// public static Task<int> SendAsync(this Socket socket, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags);
public static Task<int> SendAsync(this Socket socket, IList<ArraySegment<byte>> buffers);
// public static ValueTask<int> SendAsync(this Socket socket, ReadOnlyMemory<byte> buffer, SocketFlags socketFlags, CancellationToken cancellationToken = default(CancellationToken));
public static ValueTask<int> SendAsync(this Socket socket, ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken));
// public static Task<int> SendToAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP);
public static Task<int> SendToAsync(this Socket socket, ArraySegment<byte> buffer, EndPoint remoteEP);
}Additions to #938
// #938 overloads in comments
public static class SocketTaskExtensions
{
// public static ValueTask<int> SendToAsync(this Socket socket, ReadOnlyMemory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = default);
public static ValueTask<int> SendToAsync(this Socket socket, ReadOnlyMemory<byte> buffer, EndPoint remoteEP, CancellationToken cancellationToken = default);
// public static ValueTask<SocketReceiveFromResult> ReceiveFromAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = default);
public static ValueTask<SocketReceiveFromResult> ReceiveFromAsync(this Socket socket, Memory<byte> buffer, EndPoint remoteEP, CancellationToken cancellationToken = default);
// public static ValueTask<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = default);
public static ValueTask<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this Socket socket, Memory<byte> buffer, EndPoint remoteEP, CancellationToken cancellationToken = default);
}Consider: addition to #43933
This is not an async API but probably worth to add.
// #43933 overload in comments
public class Socket
{
// public int ReceiveMessageFrom(Span<byte> buffer, ref SocketFlags socketFlags, ref EndPoint remoteEP, out IPPacketInformation ipPacketInformation);
public int ReceiveMessageFrom(Span<byte> buffer, ref EndPoint remoteEP, out IPPacketInformation ipPacketInformation);
}@scalablecory @wfurt @antonfirsov @stephentoub Thoughts?
antonfirsov and NN---
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Net.Socketshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors