Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Task-based async methods to Socket #17710

Closed
GSPP opened this issue Jun 27, 2016 · 5 comments
Closed

Add Task-based async methods to Socket #17710

GSPP opened this issue Jun 27, 2016 · 5 comments
Milestone

Comments

@GSPP
Copy link

GSPP commented Jun 27, 2016

The Socket class is fully capable of async IO but Task-returning methods are missing. I find myself pulling in the same set of helper extensions each time I use async sockets.

Since sockets are a primary use case for async IO I'd find this API addition extremely useful.

Note, that the async methods on NetworkStream are not enough because we need async support for things like Connect as well.

@GSPP
Copy link
Author

GSPP commented Jun 27, 2016

Stephen Toub already has done some work here. I'm leaving this note to inform visitors that a decent workaround is available. As far as I can tell his code for ReceiveAsync is of great quality and is production ready.

@davidsh
Copy link
Contributor

davidsh commented Jun 27, 2016

cc: @CIPop @stephentoub

@CIPop
Copy link
Member

CIPop commented Jun 27, 2016

@GSPP
Copy link
Author

GSPP commented Jun 27, 2016

Cool, that's great news! I think this issue can be closed.

Why were extension methods chosen as opposed to regular methods? This is a rare design choice.

@CIPop
Copy link
Member

CIPop commented Jun 27, 2016

Nice! Closing.

Why were extension methods chosen as opposed to regular methods? This is a rare design choice.

It's so that System.Net.Sockets is available for all platforms including .Net Desktop 4.6. The constraint we're working around is that once we release, we cannot add new APIs to the frameworks.
Adding them as extensions allowed us to include the new APIs and their implementation in the facade lib (the glue between Core and the Desktop framework) as well as have them available within the .Net Core implementation.

Today, the implementations are the same in both cases. In the future, since for .Net Core they live next to the Socket code, they can eventually be optimized as true Task based APIs instead of wrappers over the Begin/End implementation.

@CIPop CIPop closed this as completed Jun 27, 2016
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 1.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 30, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

4 participants