Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • "Although some API do actually need to block on a Thread – and I think that is the case for listening on a socket, at least on Windows" - No, listening on sockets is truly asynchronous. Commented Aug 17, 2019 at 17:54
  • @SebastianRedl I found recv, the docs says "f no incoming data is available at the socket, the recv call blocks and waits for data to arrive according to the blocking rules defined for WSARecv with the MSG_PARTIAL flag not set unless the socket is nonblocking." and about MSG_PARTIAL I find "Be aware that the MSG_PARTIAL flag bit is not supported by all protocols." Commented Aug 17, 2019 at 18:14
  • @SebastianRedl about .NET, looking with Just Decompile, I see HttpClientHandler.SendAsync uses Task.Run. About .NET Core, I find it uses a WinHttpHandler that uses TaskFactory.StartNew. Could they not do it without spinning a thread? Commented Aug 17, 2019 at 18:20
  • The socket APIs have async methods, and those use Windows overlapped I/O, not the old WSAPI primitives. In .Net Core anyway. Commented Aug 17, 2019 at 18:30