none
C# Remote Access Tool - Socket reconnection RRS feed

  • Question

  • Hi, i am currently working on a remote access tool in C#, that through lan network different computers can connect to another (working as a server). All this project is based on socket connections. From the server side i can "control" the other computers by sending them messeges - shutting them down- restarting them - Starting processes and killing processes. The client side is just receiving the messages and completes the task. Everything are working as intended, however if the server disconnects for some reason the clients cannot reconnect back to it. The only way for the server to get disconnected is to close the program or kill the connections (It can't crash at an exception). The server is just accepting the callbacks that the clients provide so the problem should not be on the server side. Before the server goes down it sends a Disconnect message to the clients so they know that the connection is about to break. When the clients get that message i start a new thread (because i get an error if i try to reconnect from the same thread) called reconnect and try to reconnect back to the server. But that generated another issue. Apperantly i can't reconnect to the same ipendpoint. So, i searched over the internet and i found out that when a connection is stopped there is a default of 240 seconds that the port stays in TIME_WAIT. The one thing that got me intrigued is that when i restart the application it can connect to the server almost in an instant. So my question is the following. Is there something i can do to re-establish connection without restarting the application?

    Note: I am using the Connect() method to connect back to the server because i already have a thread dedicated to the reconnect process.


    Thursday, March 8, 2018 1:23 PM

Answers

  • konstantinos pap,

    Does this have anything to do with Microsoft Project, a project management application? It doesn't look like it. I suggest you re-post to a forum that deals with C# such as:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=csharpgeneral

    John

    Thursday, March 8, 2018 2:27 PM

All replies

  • konstantinos pap,

    Does this have anything to do with Microsoft Project, a project management application? It doesn't look like it. I suggest you re-post to a forum that deals with C# such as:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=csharpgeneral

    John

    Thursday, March 8, 2018 2:27 PM
  • Yeah i wasn't sure if i posted this on the right place. Thanks for letting me know and sorry for any
    inconvenience.
    Thursday, March 8, 2018 2:45 PM
  • Konstantinos pap,

    You're welcome and thanks for the feedback. Hope you find the help you need.

    John

    Thursday, March 8, 2018 4:11 PM