Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET NetworkStream.EndWrite() bytes written

The MSDN documentation clearly states that:

After obtaining the NetworkStream, you can call the EndWrite method to successfully complete the send operation and return the number of bytes sent.

Emphasis mine.

However, it returns nothing (void):

public override void EndWrite(
    IAsyncResult asyncResult
)

Am I missing something, or is this a typo (EndRead() does return bytes read).?

like image 433
Chad Schouggins Avatar asked Dec 06 '25 00:12

Chad Schouggins


1 Answers

You are not missing anything, it is a doc bug. Probably induced by copy/pasting the EndRead article. Where it very much does matter. You already know how many bytes were written, all of them.

like image 174
Hans Passant Avatar answered Dec 08 '25 14:12

Hans Passant