-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Finalize Socket API upgrade #33417
Comments
Triage:
|
There are many ways to provide data for sending (e.g. array, memory, sequence, A way around that multiplication would be to introduce a struct wrapper (a union type) that can wrap any way to provide data: struct SocketData {
byte[] Array;
Memory<byte> Memory;
IList<Memory<byte>> MemoryList;
ReadOnlySequence Sequence; //Currently not proposed
Stream Stream; //Just an idea
//Implicit conversion operators and constructors here
} And then a single overload taking such a value:
This would be strongly typed to only allow appropriate values. This concept is so scalable in terms of API surface that it becomes feasible to accept new formats such as a A similar idea can apply to receiving data. It also applies to ways to specify an endpoint (e.g. single IP, multiple IPs, hostname, eyeballs). |
That wouldn't work for the |
Cancellation support on UdpClient would be wonderful! |
Some feedback. I've just decided to not use
I agree and support. The choice I made towards
Let me reiterate. I realize my viewport is limited. I think |
So does |
@GF-Huang No, this issue is still open and .Net 5 has been released, which means it won't receive any new APIs. |
Re UdpClient changes, the underlying support in Socket is now complete so adding them to UdpClient is unblocked. I've reopened #864 to get API approval. |
Yeah, UdpClient does not seem very useful in general. It's usually better to just use Socket directly. |
triage: we should reevaluate what was already done and consider #63162. Updating |
Not included in API writeup below:
Should we stop adding to
SocketTaskExtensions
and make all of these APIs (and all the existing APIs) on top ofSocket
directly?These extensions have poor discoverability and were initially added for a Task compat library for Framework. With .NET 5, it's a good chance to clean things up.
Gathered send, scattered receive
Previous APIs took an
IList<ArraySegment<byte>
, new APIs take anIReadOnlyList<Memory<byte>>
. They are also cancellable and returnValueTask
.ReadOnlySequence
We may want to have gathered
Send
overloads forReadOnlySequence
. There is no writable sequence concept yet, so we wouldn't have a nice symmetry, but that's probably OK.Why
IReadOnlyList<ROM>
instead ofReadOnlySequence
? Multi-segment sequences are non-trivial to construct outside of Pipelines and would likely need some additional classes to make simple outside of that.SocketAsyncEventArgs
SocketAsyncEventArgs
is challenging as what are otherwise overloadable method arguments are instead exposed as properties of a class... and there already exist properties that work withbyte[]
andIList<ArraySegment>
. With a little prototyping I've been unable to find a great way to merge the existing APIs functionality-wise withMemory
-based ones.The ValueTask APIs are efficient, so I think it's easy to simply not make a public API change here. We can leave this for future if the need arises.
Connect(ConnectAlgorithm) APIs
We added a
SocketAsyncEventArgs
version of this API, but not the other overloads. This adds those.UdpClient
Spanifies and makes cancellable existing APIs.
Proposed APIs
(Edit @geoffkizer May 05 2021: I removed DisconnectAsync from above since it got approved and implemented separately.)
The text was updated successfully, but these errors were encountered: