-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Net
Milestone
Description
Update: Partially implemented, the remaining parts needs to be revisited. See #40044 (comment) -- @antonfirsov
Implementation was merged for #1793, sans the sockets factories. This tracks the remaining work to implement that issue.
The SocketsConnectionFactory will be trivial to implement: essentially, one must move the implementation over from SocketsHttpConnectionFactory, and make that class inherit from this one.
SocketsListenerFactory can reuse the same SocketsConnection, so 80% of work is already done for that as well.
class SocketsConnectionFactory : ConnectionFactory
{
// dual-mode IPv6 socket. See Socket(SocketType socketType, ProtocolType protocolType)
public SocketsConnectionFactory(SocketType socketType, ProtocolType protocolType);
// See Socket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
public SocketsConnectionFactory(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType);
// This must be thread-safe!
public override ValueTask<Connection> ConnectAsync(EndPoint? endPoint, IConnectionProperties? options = null, CancellationToken cancellationToken = default);
// These exist to provide an easy way to shim the default behavior.
// Note: Connect must call this to create its socket.
protected virtual Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, EndPoint? endPoint, IConnectionProperties? options);
protected virtual Stream CreateStream(Socket socket, IConnectionProperties? options);
protected virtual IDuplexPipe CreatePipe(Socket socket, IConnectionProperties? options);
}
class SocketsListenerFactory : ConnectionListenerFactory
{
// dual-mode IPv6 socket. See Socket(SocketType socketType, ProtocolType protocolType)
public SocketsListenerFactory(SocketType socketType, ProtocolType protocolType);
// See Socket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
public SocketsListenerFactory(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType);
// This and the listener's Accept must be thread-safe!
public override ValueTask<ConnectionListener> BindAsync(EndPoint? endPoint, IConnectionProperties? options = null, CancellationToken cancellationToken = default);
// These exist to provide an easy way for users to override default behavior.
// Note: Bind and its listener's Accept must call this to create their sockets.
protected virtual Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, EndPoint? endPoint, IConnectionProperties? options);
}tibel
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