Skip to content

Missing Socket APIs mega-issue #43935

Open
@geoffkizer

Description

@geoffkizer

We still have a few gaps in our Socket APIs where we are missing support for Task, Span/Memory, or CancellationToken.

This is a mega-issue to track all remaining work here for 6.0.

Async Socket APIs:

	public static ValueTask<Socket> AcceptAsync (this Socket socket, CancellationToken cancellationToken);
	public static ValueTask<Socket> AcceptAsync (this Socket socket, Socket acceptSocket, CancellationToken cancellationToken);
	public static ValueTask<int> SendToAsync(this Socket socket, ReadOnlyMemory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = null);
	public static ValueTask<SocketReceiveFromResult> ReceiveFromAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = null);
	public static ValueTask<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP, CancellationToken cancellationToken = null);
        public ValueTask SendFileAsync(string? fileName, CancellationToken cancellationToken = default);
        public ValueTask SendFileAsync(string? fileName, ReadOnlyMemory<byte> preBuffer, ReadOnlyMemory<byte> postBuffer, TransmitFileOptions flags, CancellationToken cancellationToken = default);
        public static ValueTask DisconnectAsync(this Socket socket, bool reuseSocket, CancellationToken cancellationToken=default);

Sync Socket APIs:

	public int SendTo(ReadOnlySpan<byte> buffer, EndPoint remoteEP);
	public int SendTo(ReadOnlySpan<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP);
	public int ReceiveFrom(Span<byte> buffer, ref EndPoint remoteEP);
	public int ReceiveFrom(Span<byte> buffer, SocketFlags socketFlags, ref EndPoint remoteEP);
        public int ReceiveMessageFrom(Span<byte> buffer, ref System.Net.Sockets.SocketFlags socketFlags, ref System.Net.EndPoint remoteEP, out System.Net.Sockets.IPPacketInformation ipPacketInformation);
        public void SendFile(string fileName, ReadOnlySpan<byte> preBuffer, ReadOnlySpan<byte> postBuffer, TransmitFileOptions flags);

Async TcpListener APIs:

	public ValueTask<Socket> AcceptSocketAsync (CancellationToken cancellationToken);
	public ValueTask<TcpClient> AcceptTcpClientAsync (CancellationToken cancellationToken);

Async TcpClient APIs:

namespace System.Net.Sockets
{
    public class TcpClient : IDisposable
    {
        public Task ConnectAsync(IPEndPoint remoteEP);
        public ValueTask ConnectAsync(IPEndPoint remoteEP, CancellationToken cancellationToken);
    }
}

UdpClient APIs:

public class UdpClient
{
    public int Send(ReadOnlySpan<byte> datagram);
    public int Send(ReadOnlySpan<byte> datagram, IPEndPoint endPoint);
    public int Send(ReadOnlySpan<byte> datagram, string hostname, int port);
    public ValueTask<int> SendAsync(ReadOnlyMemory<byte> datagram, CancellationToken cancellationToken);
    public ValueTask<int> SendAsync(ReadOnlyMemory<byte> datagram, IPEndPoint endPoint, CancellationToken cancellationToken);
    public ValueTask<UdpReceiveResult> ReceiveAsync(CancellationToken cancellationToken);
}

Related issues

Metadata

Metadata

Assignees

Labels

area-System.Net.SocketsenhancementProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributors

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions