|
422 | 422 |
|
423 | 423 | ## Remarks
|
424 | 424 | > [!IMPORTANT]
|
425 |
| -> This is a compatibility API, we don't recommend to use the [APM](/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm) (Begin / End) methods for new development. Instead, use the Task-based equivalents. |
| 425 | +> This is a compatibility API. We don't recommend using the [APM](/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm) (Begin / End) methods for new development. Instead, use the Task-based equivalents. |
426 | 426 |
|
427 | 427 | You can pass a callback that implements <xref:System.AsyncCallback> to <xref:System.Net.Sockets.NetworkStream.BeginRead%2A> in order to get notified about the completion of the operation. Note that if the underlying network stack completes the operation synchronously, the callback will be executed inline, during the call to <xref:System.Net.Sockets.NetworkStream.BeginRead%2A>. In this case, the <xref:System.IAsyncResult.CompletedSynchronously%2A> property on the returned <xref:System.IAsyncResult> will be set to `true` to indicate that the method completed synchronously. Use the <xref:System.IAsyncResult.AsyncState%2A> property of the <xref:System.IAsyncResult> to obtain the state object passed to the <xref:System.Net.Sockets.NetworkStream.BeginRead%2A> method.
|
428 | 428 |
|
429 | 429 | The <xref:System.Net.Sockets.NetworkStream.BeginRead%2A> operation must be completed by calling the <xref:System.Net.Sockets.NetworkStream.EndRead%2A> method. Typically, the method is invoked by the provided <xref:System.AsyncCallback> delegate. <xref:System.Net.Sockets.NetworkStream.EndRead%2A> will block the calling thread until the operation is completed.
|
430 | 430 |
|
431 |
| - The operation reads as much data as is available, up to the number of bytes specified by the `size` parameter. |
| 431 | + The operation reads as much data as is available, up to the number of bytes specified by the `count` parameter. |
432 | 432 |
|
433 | 433 | > [!NOTE]
|
434 | 434 | > If you receive an <xref:System.IO.IOException>, check the <xref:System.Exception.InnerException%2A> property to determine if it was caused by a <xref:System.Net.Sockets.SocketException>. If so, use the <xref:System.Net.Sockets.SocketException.ErrorCode%2A> property to obtain the specific error code.
|
|
540 | 540 |
|
541 | 541 | ## Remarks
|
542 | 542 | > [!IMPORTANT]
|
543 |
| -> This is a compatibility API, we don't recommend to use the [APM](/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm) (Begin / End) methods for new development. Instead, use the Task-based equivalents. |
| 543 | +> This is a compatibility API. We don't recommend using the [APM](/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm) (Begin / End) methods for new development. Instead, use the Task-based equivalents. |
544 | 544 |
|
545 | 545 | You can pass a callback that implements <xref:System.AsyncCallback> to <xref:System.Net.Sockets.NetworkStream.BeginWrite%2A> in order to get notified about the completion of the operation. Note that if the underlying network stack completes the operation synchronously, the callback will be executed inline, during the call to <xref:System.Net.Sockets.NetworkStream.BeginWrite%2A>. In this case, the <xref:System.IAsyncResult.CompletedSynchronously%2A> property on the returned <xref:System.IAsyncResult> will be set to `true` to indicate that the method completed synchronously. Use the <xref:System.IAsyncResult.AsyncState%2A> property of the <xref:System.IAsyncResult> to obtain the state object passed to the <xref:System.Net.Sockets.NetworkStream.BeginWrite%2A> method.
|
546 | 546 |
|
@@ -1113,12 +1113,10 @@ The Close method frees both unmanaged and managed resources associated with the
|
1113 | 1113 |
|
1114 | 1114 | ## Remarks
|
1115 | 1115 | > [!IMPORTANT]
|
1116 |
| -> This is a compatibility API, we don't recommend to use the [APM](/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm) (Begin / End) methods for new development. Instead, use the Task-based equivalents. |
| 1116 | +> This is a compatibility API. We don't recommend using the [APM](/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm) (Begin / End) methods for new development. Instead, use the Task-based equivalents. |
1117 | 1117 |
|
1118 | 1118 | The <xref:System.Net.Sockets.NetworkStream.EndRead%2A> method completes the read operation started by the <xref:System.Net.Sockets.NetworkStream.BeginRead%2A> method. You need to pass the <xref:System.IAsyncResult> created by the matching <xref:System.Net.Sockets.NetworkStream.BeginRead%2A> call. <xref:System.Net.Sockets.NetworkStream.EndRead%2A> will block the calling thread until the operation is completed.
|
1119 | 1119 |
|
1120 |
| - The operation reads as much data as is available, up to the number of bytes specified by the `size` parameter. |
1121 |
| -
|
1122 | 1120 | > [!NOTE]
|
1123 | 1121 | > If you receive an <xref:System.IO.IOException>, check the <xref:System.Exception.InnerException%2A> property to determine if it was caused by a <xref:System.Net.Sockets.SocketException>. If so, use the <xref:System.Net.Sockets.SocketException.ErrorCode%2A> property to obtain the specific error code.
|
1124 | 1122 |
|
@@ -1179,12 +1177,10 @@ The Close method frees both unmanaged and managed resources associated with the
|
1179 | 1177 |
|
1180 | 1178 | ## Remarks
|
1181 | 1179 | > [!IMPORTANT]
|
1182 |
| -> This is a compatibility API, we don't recommend to use the [APM](/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm) (Begin / End) methods for new development. Instead, use the Task-based equivalents. |
| 1180 | +> This is a compatibility API. We don't recommend using the [APM](/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm) (Begin / End) methods for new development. Instead, use the Task-based equivalents. |
1183 | 1181 |
|
1184 | 1182 | The <xref:System.Net.Sockets.NetworkStream.EndWrite%2A> method completes the read operation started by the <xref:System.Net.Sockets.NetworkStream.BeginWrite%2A> method. You need to pass the <xref:System.IAsyncResult> created by the matching <xref:System.Net.Sockets.NetworkStream.BeginWrite%2A> call. <xref:System.Net.Sockets.NetworkStream.EndWrite%2A> will block the calling thread until the operation is completed.
|
1185 | 1183 |
|
1186 |
| - The operation reads as much data as is available, up to the number of bytes specified by the `size` parameter. |
1187 |
| -
|
1188 | 1184 | > [!NOTE]
|
1189 | 1185 | > If you receive an <xref:System.IO.IOException>, check the <xref:System.Exception.InnerException%2A> property to determine if it was caused by a <xref:System.Net.Sockets.SocketException>. If so, use the <xref:System.Net.Sockets.SocketException.ErrorCode%2A> property to obtain the specific error code.
|
1190 | 1186 |
|
@@ -1552,15 +1548,14 @@ There is a failure reading from the network.</exception>
|
1552 | 1548 | <format type="text/markdown"><![CDATA[
|
1553 | 1549 |
|
1554 | 1550 | ## Remarks
|
1555 |
| - This method reads data into `buffer` and returns the number of bytes successfully read. The `Read` operation reads as much data as is available, up to the number of bytes specified by the `size` parameter. |
| 1551 | + This method reads data into `buffer` and returns the number of bytes successfully read. The `Read` operation reads as much data as is available, up to the number of bytes specified by the `count` parameter. |
1556 | 1552 |
|
1557 | 1553 | > [!NOTE]
|
1558 | 1554 | > Check to see if the <xref:System.Net.Sockets.NetworkStream> is readable by calling the <xref:System.Net.Sockets.NetworkStream.CanRead> property. If you attempt to read from a <xref:System.Net.Sockets.NetworkStream> that is not readable, you will get an <xref:System.InvalidOperationException>.
|
1559 | 1555 |
|
1560 | 1556 | > [!NOTE]
|
1561 | 1557 | > If you receive an <xref:System.IO.IOException>, check the <xref:System.Exception.InnerException> property to determine if it was caused by a <xref:System.Net.Sockets.SocketException>. If so, use the <xref:System.Net.Sockets.SocketException.ErrorCode> property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error.
|
1562 | 1558 |
|
1563 |
| -
|
1564 | 1559 | ## Examples
|
1565 | 1560 | The following code example reads data from the <xref:System.Net.Sockets.NetworkStream> into a buffer. If data is available, it continues reading until the end of the stream is reached, appending the received data to a <xref:System.Text.StringBuilder>.
|
1566 | 1561 | :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/NetworkStream/Overview/source.cs" id="Snippet4":::
|
@@ -1776,7 +1771,7 @@ There is a failure reading from the network.</exception>
|
1776 | 1771 | <format type="text/markdown"><![CDATA[
|
1777 | 1772 |
|
1778 | 1773 | ## Remarks
|
1779 |
| - This method reads data into `buffer` and returns the number of bytes successfully read. The `ReadAsync` operation reads as much data as is available, up to the number of bytes specified by the `size` parameter. |
| 1774 | + This method reads data into `buffer` and returns the number of bytes successfully read. The `ReadAsync` operation reads as much data as is available, up to the number of bytes specified by the `count` parameter. |
1780 | 1775 |
|
1781 | 1776 | > [!NOTE]
|
1782 | 1777 | > Check to see if the <xref:System.Net.Sockets.NetworkStream> is readable by calling the <xref:System.Net.Sockets.NetworkStream.CanRead> property. If you attempt to read from a <xref:System.Net.Sockets.NetworkStream> that is not readable, you will get an <xref:System.InvalidOperationException>.
|
@@ -2218,7 +2213,7 @@ There was a failure while writing to the network.</exception>
|
2218 | 2213 | <format type="text/markdown"><![CDATA[
|
2219 | 2214 |
|
2220 | 2215 | ## Remarks
|
2221 |
| -This method starts at the specified `offset` and sends `size` bytes from the contents of `buffer` to the network. The `Write` method blocks until the requested number of bytes is sent or a <xref:System.Net.Sockets.SocketException> is thrown. |
| 2216 | +This method starts at the specified `offset` and sends `count` bytes from the contents of `buffer` to the network. The `Write` method blocks until the requested number of bytes is sent or a <xref:System.Net.Sockets.SocketException> is thrown. |
2222 | 2217 |
|
2223 | 2218 | > [!NOTE]
|
2224 | 2219 | > Check to see if the <xref:System.Net.Sockets.NetworkStream> is writable by calling the <xref:System.Net.Sockets.NetworkStream.CanWrite> property. If you attempt to write to a <xref:System.Net.Sockets.NetworkStream> that is not writable, you will get an <xref:System.InvalidOperationException>.
|
@@ -2438,7 +2433,7 @@ There was a failure while writing to the network.</exception>
|
2438 | 2433 | <remarks>
|
2439 | 2434 | <format type="text/markdown"><![CDATA[
|
2440 | 2435 | ## Remarks
|
2441 |
| -This method starts at the specified `offset` and sends `size` bytes from the contents of `buffer` to the network. |
| 2436 | +This method starts at the specified `offset` and sends `count` bytes from the contents of `buffer` to the network. |
2442 | 2437 |
|
2443 | 2438 | > [!NOTE]
|
2444 | 2439 | > Check to see if the <xref:System.Net.Sockets.NetworkStream> is writable by calling the <xref:System.Net.Sockets.NetworkStream.CanWrite> property. If you attempt to write to a <xref:System.Net.Sockets.NetworkStream> that is not writable, you will get an <xref:System.InvalidOperationException>.
|
|
0 commit comments