-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Memory support to SendPacketElements #45267
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsProposed APInamespace 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 Memory<byte>? MemoryBuffer { get; }
}
} This is modeled on how we added Memory support to SocketAsyncEventArgs. If you use a new Memory constructor overload, then:
If you use an old byte[] constructor overload, then:
|
if this is the case, there's no reason for the |
Besides that it shouldn't be nullable anyway. If not set, it's But this is superceded by @scalablecory's comment. |
SendPacketElements can also be a file (or file segment). In that case, MemoryBuffer will return null, as Buffer does today. |
...or MemoyBuffer will just be empty (instead of being null). For span-overloads if no data is given, they're empty and we don't have nullable spans as arguments where null means void. |
I think it's different. In this case you're not using a Memory at all; you are using a file. |
Ah, ok there it is also nullable, so it should be the same here. |
namespace System.Net.Sockets
{
public partial 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; }
public SendPacketsElement(ReadOnlyMemory<byte> buffer);
public SendPacketsElement(ReadOnlyMemory<byte> buffer, bool endOfPacket);
public ReadOnlyMemory<byte>? MemoryBuffer { get; }
}
} |
Proposed API
This is modeled on how we added Memory support to SocketAsyncEventArgs.
If you use a new Memory constructor overload, then:
If you use an old byte[] constructor overload, then:
The text was updated successfully, but these errors were encountered: