Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Add Memory-based APIs to Sockets and NetworkStream #24431

Merged
merged 1 commit into from
Oct 5, 2017

Conversation

stephentoub
Copy link
Member

Fixes https://github.com/dotnet/corefx/issues/22387
Fixes https://github.com/dotnet/corefx/issues/22608

@geoffkizer, I separated https://github.com/dotnet/corefx/issues/24429 out into a separate issue to avoid colliding with the changes you're making in the guts of Socket. These changes stop just below the surface of SocketAsyncEventArgs; once your changes go in, we can then push the use of Memory<byte> further down, whereas these changes just extract the array from it (and throw for now if there is no array).

cc: @geoffkizer, @Priya91, @wfurt, @davidsh, @KrzysztofCwalina, @ahsonkhan

@@ -17,4 +17,16 @@ public partial class Socket : System.IDisposable
public int Send(ReadOnlySpan<byte> buffer, System.Net.Sockets.SocketFlags socketFlags) { throw null; }
public int Send(ReadOnlySpan<byte> buffer, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode) { throw null; }
}

public partial static class SocketTaskExtensions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding these as extension methods? Why not just add them as new regular methods (i.e. new APIs)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the API review I believe we'd elected to keep them next to where the existing Task-based methods are. I don't have a strong preference, though; @weshaggard, @terrajobst, @KrzysztofCwalina, opinions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we added them a long time ago as extension methods because we didn't have a good plan for adding new APIs to .NET Core vs. figuring out how to eventually add them to .NET Framework and then .NETStandard.

But I think at this point, we should be adding them as new APIs (not extension methods) just like we're doing for SslStream (ALPN, SNI). I.e. add them to netcore first, then figure out how/when to add them to .net framework so that eventually they can roll into a new netstandard.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a preference. Both approaches seem reasonable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried it, and realized it's a breaking change unless we also add the existing extension methods as instance methods. Otherwise, the compiler won't consider the extension methods as valid targets once it finds the instance methods of the same name, and due to signature differences, various uses can then fail to compile.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened https://github.com/dotnet/corefx/issues/24442 to track revisiting this in an API discussion. I'll go ahead with this PR to keep things unblocked.

@stephentoub stephentoub merged commit b6ef0f1 into dotnet:master Oct 5, 2017
@stephentoub stephentoub deleted the socket_memory branch October 5, 2017 20:53
@karelz karelz added this to the 2.1.0 milestone Oct 11, 2017
pjanotti pushed a commit to pjanotti/corefx that referenced this pull request Oct 31, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants