You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Detailed docs on Socket.Read* and NetworkStream.Receive* return values (#10983)
The wording is mostly borrowed from the `Stream.Read*` variants but saying `the peer socket performed a graceful shutdown` instead of `end of the stream has been reached`, which describes the EOF reason more specifically in this case.
---------
Co-authored-by: Genevieve Warren <[email protected]>
Copy file name to clipboardExpand all lines: xml/System.Net.Sockets/NetworkStream.xml
+6-6
Original file line number
Diff line number
Diff line change
@@ -1107,7 +1107,7 @@ The Close method frees both unmanaged and managed resources associated with the
1107
1107
<Docs>
1108
1108
<paramname="asyncResult">An <seecref="T:System.IAsyncResult" /> that represents an asynchronous call.</param>
1109
1109
<summary>Handles the end of an asynchronous read.</summary>
1110
-
<returns>The number of bytes read from the <seecref="T:System.Net.Sockets.NetworkStream" />.</returns>
1110
+
<returns>The number of bytes read from the <seecref="T:System.Net.Sockets.NetworkStream" />, between zero (0) and the number of bytes requested. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, read operations might complete immediately or might not complete until at least one byte is available (but without consuming any data).</returns>
1111
1111
<remarks>
1112
1112
<formattype="text/markdown"><![CDATA[
1113
1113
@@ -1466,7 +1466,7 @@ The Close method frees both unmanaged and managed resources associated with the
1466
1466
<Docs>
1467
1467
<paramname="buffer">A region of memory to store data read from the <seecref="T:System.Net.Sockets.NetworkStream" />.</param>
1468
1468
<summary>Reads data from the <seecref="T:System.Net.Sockets.NetworkStream" /> and stores it to a span of bytes in memory.</summary>
1469
-
<returns>The number of bytes read from the <seecref="T:System.Net.Sockets.NetworkStream" />.</returns>
1469
+
<returns>The total number of bytes read into the buffer, between zero (0) and the length of the buffer. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.</returns>
1470
1470
<remarks>
1471
1471
<formattype="text/markdown"><![CDATA[
1472
1472
@@ -1543,7 +1543,7 @@ There is a failure reading from the network.</exception>
1543
1543
<paramname="size">The number of bytes to read from the <seecref="T:System.Net.Sockets.NetworkStream" />.</param>
1544
1544
<paramname="count">The number of bytes to read from the <seecref="T:System.Net.Sockets.NetworkStream" />.</param>
1545
1545
<summary>Reads data from the <seecref="T:System.Net.Sockets.NetworkStream" /> and stores it to a byte array.</summary>
1546
-
<returns>The number of bytes read from the <seecref="T:System.Net.Sockets.NetworkStream" />.</returns>
1546
+
<returns>The total number of bytes read into the buffer between zero (0) and the requested count. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.</returns>
1547
1547
<remarks>
1548
1548
<formattype="text/markdown"><![CDATA[
1549
1549
@@ -1695,7 +1695,7 @@ There is a failure reading from the network.</exception>
1695
1695
<paramname="buffer">The buffer to write the data to.</param>
1696
1696
<paramname="cancellationToken">The token to monitor for cancellation requests.</param>
1697
1697
<summary>Reads data from the <seecref="T:System.Net.Sockets.NetworkStream" /> and stores it in a byte memory range as an asynchronous operation.</summary>
1698
-
<returns>A <seecref="T:System.Threading.Tasks.ValueTask`1" /> that represents the asynchronous read operation. The value of its <seecref="P:System.Threading.Tasks.ValueTask`1.Result" /> property contains the total number of bytes read into <paramrefname="buffer" />.</returns>
1698
+
<returns>A <seecref="T:System.Threading.Tasks.ValueTask`1" /> that represents the asynchronous read operation. The value of its <seecref="P:System.Threading.Tasks.ValueTask`1.Result" /> property contains the total number of bytes read into <paramrefname="buffer" /> between zero (0) and the number of bytes requested. The result value is zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, read operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).</returns>
1699
1699
<remarks>
1700
1700
<formattype="text/markdown"><![CDATA[
1701
1701
@@ -1766,7 +1766,7 @@ There is a failure reading from the network.</exception>
1766
1766
<paramname="count">The number of bytes to read from the <seecref="T:System.Net.Sockets.NetworkStream" />.</param>
1767
1767
<paramname="cancellationToken">The token to monitor for cancellation requests.</param>
1768
1768
<summary>Reads data from the <seecref="T:System.Net.Sockets.NetworkStream" /> and stores it to a specified range of a byte array as an asynchronous operation.</summary>
1769
-
<returns>A task that represents the asynchronous read operation. The value of its <seecref="P:System.Threading.Tasks.Task`1.Result" /> property contains the total number of bytes read into <paramrefname="buffer" />.</returns>
1769
+
<returns>A task that represents the asynchronous read operation. The value of its <seecref="P:System.Threading.Tasks.Task`1.Result" /> property contains the total number of bytes read into <paramrefname="buffer" /> between zero (0) and the number of bytes requested. The result value is zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, read operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).</returns>
1770
1770
<remarks>
1771
1771
<formattype="text/markdown"><![CDATA[
1772
1772
@@ -1821,7 +1821,7 @@ There is a failure reading from the network.</exception>
1821
1821
<Parameters />
1822
1822
<Docs>
1823
1823
<summary>Reads a byte from the <seecref="T:System.Net.Sockets.NetworkStream" /> and advances the position within the stream by one byte, or returns -1 if at the end of the stream.</summary>
1824
-
<returns>The unsigned byte cast to an <seecref="T:System.Int32" />, or -1 if at the end of the stream.</returns>
1824
+
<returns>The unsigned byte cast to an <seecref="T:System.Int32" />, or -1 if at the end of the stream because the peer socket performed a graceful shutdown.</returns>
0 commit comments