问题
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).?
回答1:
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.
来源:https://stackoverflow.com/questions/17537637/net-networkstream-endwrite-bytes-written