The System.Net.Sockets TcpListener class in C# is used to accept incoming connection requests from clients over a TCP network. The Stop method is used to stop the TcpListener object from listening for incoming requests.
Examples:
Example 1 - Stop TcpListener:
TcpListener listener = new TcpListener(IPAddress.Any, 8080); listener.Start();
//Do some work here
listener.Stop();
In this example, a TcpListener object is created and started listening for incoming requests on port 8080. The listener object is then stopped using the Stop method.
Example 2 - Stop TcpListener using Async:
TcpListener listener = new TcpListener(IPAddress.Any, 8080); listener.Start();
//Do some work here
await listener.StopAsync();
In this example, the StopAsync method is used to stop the TcpListener object asynchronously.
Package Library:
The System.Net.Sockets namespace is included in the .NET Core framework and .NET Framework class libraries. It is part of the System assembly.
C# (CSharp) System.Net.Sockets TcpListener.Stop - 60 examples found. These are the top rated real world C# (CSharp) examples of System.Net.Sockets.TcpListener.Stop extracted from open source projects. You can rate examples to help us improve the quality of examples.