From b79650a4c9b811f6f91d7287252c15a88dc0c436 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 3 Feb 2025 17:39:00 -0800 Subject: [PATCH] fixes #10895 --- xml/System.Net.Sockets/NetworkStream.xml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/xml/System.Net.Sockets/NetworkStream.xml b/xml/System.Net.Sockets/NetworkStream.xml index 0eeeedcf50c..cc06499f472 100644 --- a/xml/System.Net.Sockets/NetworkStream.xml +++ b/xml/System.Net.Sockets/NetworkStream.xml @@ -422,13 +422,13 @@ ## Remarks > [!IMPORTANT] -> 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. +> 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. You can pass a callback that implements to 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 . In this case, the property on the returned will be set to `true` to indicate that the method completed synchronously. Use the property of the to obtain the state object passed to the method. The operation must be completed by calling the method. Typically, the method is invoked by the provided delegate. will block the calling thread until the operation is completed. - The operation reads as much data as is available, up to the number of bytes specified by the `size` parameter. + The operation reads as much data as is available, up to the number of bytes specified by the `count` parameter. > [!NOTE] > If you receive an , check the property to determine if it was caused by a . If so, use the property to obtain the specific error code. @@ -540,7 +540,7 @@ ## Remarks > [!IMPORTANT] -> 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. +> 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. You can pass a callback that implements to 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 . In this case, the property on the returned will be set to `true` to indicate that the method completed synchronously. Use the property of the to obtain the state object passed to the method. @@ -1113,12 +1113,10 @@ The Close method frees both unmanaged and managed resources associated with the ## Remarks > [!IMPORTANT] -> 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. +> 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. The method completes the read operation started by the method. You need to pass the created by the matching call. will block the calling thread until the operation is completed. - The operation reads as much data as is available, up to the number of bytes specified by the `size` parameter. - > [!NOTE] > If you receive an , check the property to determine if it was caused by a . If so, use the property to obtain the specific error code. @@ -1179,12 +1177,10 @@ The Close method frees both unmanaged and managed resources associated with the ## Remarks > [!IMPORTANT] -> 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. +> 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. The method completes the read operation started by the method. You need to pass the created by the matching call. will block the calling thread until the operation is completed. - The operation reads as much data as is available, up to the number of bytes specified by the `size` parameter. - > [!NOTE] > If you receive an , check the property to determine if it was caused by a . If so, use the property to obtain the specific error code. @@ -1552,7 +1548,7 @@ There is a failure reading from the network. [!NOTE] > Check to see if the is readable by calling the property. If you attempt to read from a that is not readable, you will get an . @@ -1560,7 +1556,6 @@ There is a failure reading from the network. > [!NOTE] > If you receive an , check the property to determine if it was caused by a . If so, use the 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. - ## Examples The following code example reads data from the into a buffer. If data is available, it continues reading until the end of the stream is reached, appending the received data to a . :::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. [!NOTE] > Check to see if the is readable by calling the property. If you attempt to read from a that is not readable, you will get an . @@ -2218,7 +2213,7 @@ There was a failure while writing to the network. is thrown. +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 is thrown. > [!NOTE] > Check to see if the is writable by calling the property. If you attempt to write to a that is not writable, you will get an . @@ -2438,7 +2433,7 @@ There was a failure while writing to the network. [!NOTE] > Check to see if the is writable by calling the property. If you attempt to write to a that is not writable, you will get an .