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!

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top