Question

I am having trouble reconnecting a TCPClient (actual class name from C#) to its server. Is there a well defined way of doing this? Do I need to manage the tcp connection at the server as well if a client is trying to reconnect on the same port,

Thanks!

Was it helpful?

Solution

Most of the time you should do it the same way that you first connected to it. Just don't forget to close the connection before trying to reconnect.

Maybe a little bit more info is needed because maybe your trouble is elsewhere.

Do you call a simple "Receive" command and then close the connection and try to reconnect later. Or are you trying to "BeginReceived" (Async connection) then you would need to handle the ObjectDisposed Exception when you will disconnect and after that reconnect

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top