Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove APM samples for TCPClient and TCPListener #8603

Merged
merged 6 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ ref class TcpClientExamples
}
// </Snippet7>

// <Snippet4>
static void DoBeginConnect1( String^ host, int port )
{
// Connect asynchronously to the specifed host.
Expand All @@ -79,9 +78,7 @@ ref class TcpClientExamples
connectDone->WaitOne();
Console::WriteLine( "Connection established" );
}
// </Snippet4>

// <Snippet5>
// Connect asynchronously to the specifed host.
static void DoBeginConnect2( String^ host, int port )
{
Expand All @@ -95,9 +92,7 @@ ref class TcpClientExamples
connectDone->WaitOne();
Console::WriteLine( "Connection established" );
}
// </Snippet5>

// <Snippet6>
// Connect asynchronously to the specifed host.
static void DoBeginConnect3( String^ host, int port )
{
Expand All @@ -110,7 +105,6 @@ ref class TcpClientExamples
connectDone->WaitOne();
Console::WriteLine( "Connection established" );
}
// </Snippet6>
};

int main()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace TcpListenerExample
}
// </Snippet3>

// <Snippet4>
// Thread signal.
public:
static ManualResetEvent^ ClientConnected;
Expand Down Expand Up @@ -73,9 +72,7 @@ namespace TcpListenerExample
// Signal the calling thread to continue.
ClientConnected->Set();
}
// </Snippet4>

// <Snippet5>
// Thread signal.
public:
static ManualResetEvent^ TcpClientConnected;
Expand Down Expand Up @@ -120,7 +117,6 @@ namespace TcpListenerExample
TcpClientConnected->Set();

}
// </Snippet5>

public:
static void Main()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ static void DoConnect(string host, int port)
}
// </Snippet8>

// <Snippet7>
public static ManualResetEvent connectDone =
new ManualResetEvent(false);

Expand All @@ -62,9 +61,7 @@ public static void ConnectCallback(IAsyncResult ar)
TcpClient t = (TcpClient)ar.AsyncState;
t.EndConnect(ar);
}
// </Snippet7>

// <Snippet4>
public static void DoBeginConnect1(string host, int port)
{
// Connect asynchronously to the specifed host.
Expand All @@ -84,9 +81,7 @@ public static void DoBeginConnect1(string host, int port)

Console.WriteLine("Connection established");
}
// </Snippet4>

// <Snippet5>
// Connect asynchronously to the specifed host.
public static void DoBeginConnect2(string host, int port)
{
Expand All @@ -104,9 +99,7 @@ public static void DoBeginConnect2(string host, int port)

Console.WriteLine("Connection established");
}
// </Snippet5>

// <Snippet6>
// Connect asynchronously to the specifed host.
public static void DoBeginConnect3(string host, int port)
{
Expand All @@ -124,7 +117,6 @@ public static void DoBeginConnect3(string host, int port)

Console.WriteLine("Connection established");
}
// </Snippet6>

[STAThread]
static void Main(string[] args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public static void DoStart(TcpListener t, int backlog)
}
// </Snippet3>

// <Snippet4>
// Thread signal.
public static ManualResetEvent clientConnected =
new ManualResetEvent(false);
Expand Down Expand Up @@ -67,9 +66,7 @@ public static void DoAcceptSocketCallback(IAsyncResult ar)
// Signal the calling thread to continue.
clientConnected.Set();
}
// </Snippet4>

// <Snippet5>
// Thread signal.
public static ManualResetEvent tcpClientConnected =
new ManualResetEvent(false);
Expand Down Expand Up @@ -112,7 +109,6 @@ public static void DoAcceptTcpClientCallback(IAsyncResult ar)
// Signal the calling thread to continue.
tcpClientConnected.Set();
}
// </Snippet5>

[STAThread]
static void Main()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Class newListener
Console.WriteLine("started listening")
End Sub
' </Snippet3>
' <Snippet4>

' Thread signal.
Public Shared clientConnected As New ManualResetEvent(False)

Expand Down Expand Up @@ -58,8 +58,7 @@ Class newListener
' Signal the calling thread to continue.
clientConnected.Set()
End Sub
' </Snippet4>
' <Snippet5>

' Thread signal.
Public Shared tcpClientConnected As New ManualResetEvent(False)

Expand Down Expand Up @@ -98,8 +97,7 @@ Class newListener
' Signal the calling thread to continue.
tcpClientConnected.Set()
End Sub

' </Snippet5>

<STAThread()> _
Shared Sub Main()
Dim listener As New TcpListener(Dns.GetHostAddresses("")(0), 4242)
Expand Down
17 changes: 1 addition & 16 deletions xml/System.Net.Sockets/TcpClient.xml
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,7 @@ The `Available` property is a way to determine whether data is queued for readin

For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously).



## Examples
The following code example creates a <xref:System.Net.Sockets.TcpClient> and connects to a remote host.

:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp" id="Snippet6":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/Available/newtcpclient.cs" id="Snippet6":::


]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="host" /> parameter is <see langword="null" />.</exception>
Expand Down Expand Up @@ -1898,14 +1891,6 @@ The `Available` property is a way to determine whether data is queued for readin
> [!NOTE]
> If you receive a <xref:System.Net.Sockets.SocketException>, use <xref:System.Net.Sockets.SocketException.ErrorCode%2A?displayProperty=nameWithType> to obtain the specific error code. After you have obtained this code, you can 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 ends the asynchronous connection attempt.

:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp" id="Snippet7":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/Available/newtcpclient.cs" id="Snippet7":::

]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="asyncResult" /> parameter is <see langword="null" />.</exception>
Expand Down
43 changes: 4 additions & 39 deletions xml/System.Net.Sockets/TcpListener.xml
Original file line number Diff line number Diff line change
Expand Up @@ -842,16 +842,7 @@

> [!NOTE]
> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing).



## Examples
The following code example demonstrates the use of the <xref:System.Net.Sockets.TcpListener.BeginAcceptSocket%2A> method to create and connect a socket. The callback delegate calls the <xref:System.Net.Sockets.TcpListener.EndAcceptSocket%2A> method to end the asynchronous request.

:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp" id="Snippet4":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/BeginAcceptSocket/tcpserver.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet4":::


]]></format>
</remarks>
<exception cref="T:System.Net.Sockets.SocketException">An error occurred while attempting to access the socket.</exception>
Expand Down Expand Up @@ -921,16 +912,7 @@

> [!NOTE]
> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing).



## Examples
The following code example demonstrates the use of the <xref:System.Net.Sockets.TcpListener.BeginAcceptTcpClient%2A> method to create and connect a socket. The callback delegate calls the <xref:System.Net.Sockets.TcpListener.EndAcceptTcpClient%2A> method to end the asynchronous request.

:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp" id="Snippet5":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/BeginAcceptSocket/tcpserver.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet5":::


]]></format>
</remarks>
<exception cref="T:System.Net.Sockets.SocketException">An error occurred while attempting to access the socket.</exception>
Expand Down Expand Up @@ -1060,16 +1042,7 @@

> [!NOTE]
> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing).



## Examples
The following code example demonstrates the use of the <xref:System.Net.Sockets.TcpListener.BeginAcceptSocket%2A> method to create and connect a socket. The callback delegate calls the <xref:System.Net.Sockets.TcpListener.EndAcceptSocket%2A> method to end the asynchronous request.

:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp" id="Snippet4":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/BeginAcceptSocket/tcpserver.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet4":::


]]></format>
</remarks>
<exception cref="T:System.ObjectDisposedException">The underlying <see cref="T:System.Net.Sockets.Socket" /> has been closed.</exception>
Expand Down Expand Up @@ -1135,15 +1108,7 @@
> [!NOTE]
> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing).



## Examples
The following code example demonstrates the use of the <xref:System.Net.Sockets.TcpListener.BeginAcceptTcpClient%2A> method to create and connect a socket. The callback delegate calls the <xref:System.Net.Sockets.TcpListener.EndAcceptTcpClient%2A> method to end the asynchronous request.

:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp" id="Snippet5":::
:::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/BeginAcceptSocket/tcpserver.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet5":::


]]></format>
</remarks>
</Docs>
Expand Down