© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
47 replies
maxmahem

Canceling TcpClient after TcpListener has been stopped

So, I may have done this completely right, but I'm a bit unsure on the behavior. I'm creating TcpClients with
AcceptTcpClientAsync
AcceptTcpClientAsync
and passing it a
CancellationToken
CancellationToken
which does seem to end the TcpClients, but I guess I'm expecting to see a more graceful end in my TcpCleints which I am not.

To wit, I'm expecting to end up hitting
client.Close
client.Close
and then get the "Client disconnected" message, which isn't happening.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

SocketException, TCPListener, TCPClient reason?
C#CC# / help
2y ago
✅ TcpClient is connected to TcpListener but TcpListener isn't connected...
C#CC# / help
3y ago
❔ Assignment: TCPListener that recieves and returns to tcpClient
C#CC# / help
3y ago
TcpClient connection
C#CC# / help
4y ago