-
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.Sockets
Milestone
Description
Proposed API
namespace System.Net.Sockets
{
public class SendPacketsElement
{
// Existing APIs:
public SendPacketsElement(byte[] buffer);
public SendPacketsElement(byte[] buffer, int offset, int count);
public SendPacketsElement(byte[] buffer, int offset, int count, bool endOfPacket);
public byte[]? Buffer { get; }
public int Offset { get; }
public int Count { get; }
// Proposed APIs:
public SendPacketsElement(ReadOnlyMemory<byte> buffer);
public SendPacketsElement(ReadOnlyMemory<byte> buffer, bool endOfPacket);
public ReadOnlyMemory<byte>? MemoryBuffer { get; }
}
}This is modeled on how we added Memory support to SocketAsyncEventArgs.
If you use a new Memory constructor overload, then:
- MemoryBuffer will return the ReadOnlyMemory that you passed to the constructor
- Buffer will return null
- Offset will return 0
- Count will return MemoryBuffer.Length
If you use an old byte[] constructor overload, then:
- MemoryBuffer will return a ReadOnlyMemory constructed from the byte[], offset, and count you passed to the constructor.
- Buffer, Offset, and Count will return the values you passed to the constructor (as today)
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.Sockets