Skip to content

Will Socket.SendAsync send everything in 1 call? #100436

Answered by stephentoub
xqrzd asked this question in Q&A
Discussion options

You must be logged in to vote

We should update the docs. As long as the Socket.Blocking is true, for a connection-oriented protocol (e.g. TCP), Socket.SendAsync will ensure all the data has been sent (from the perspective of the application) and you do not need a loop. This is why NetworkStream.WriteAsync doesn't have or need a loop.

On Windows, the implementation uses WSASend, which makes this guarantee. And on Unix, the implementation has its own loop to provide a similar guarantee.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@xqrzd
Comment options

@Clockwork-Muse
Comment options

Comment options

You must be logged in to vote
2 replies
@xqrzd
Comment options

@kasperk81
Comment options

Answer selected by xqrzd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants