I have a problem, I developed the Client and Server shell for personal use, but, unfortunately, due to insufficient knowledge in network programming, I have problems with TIME_WAIT while connecting to the client. My client tries to make several connections to the same host for a short period of time, I found out that the main reason for this is that I am trying to reuse the socket and it goes into TIME_WAIT state because I close the connection without graceful shutdowns. I would like to know the correct template for closing a connection using .NET sockets if I use Async APIs intensively, such as ConnectAsync, AcceptAsync, SendAsync, ReceiveAsync, DisconnectAsync (DisconnectAsync - socket reuse)
source share