开发者

Reliably reconnect to the server TCPClient C#

I am having trouble reconnecting a TCPClient 开发者_StackOverflow(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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜