automatic client reconnection

01/01/2016 19:14 Isoline*#1
so basically, im trying to create an automatic method that will simply detect if the current client is disconnected, and if so simply, reconnect it, and resume its current ongoing work, the part the im stuck at is how to "reconnect" part.
for starters, i wanted to make it safe, so i just said, well, lets close everything, and i disposed all sockets and aborted all threads, but then i could not reconnect the gateway socket, due to port exhustion, or simply could not connect to the same ip/port, also i couldnt create an entierly new thread and start a client from there, due to "thread state is running or terminated and it cannot restart", well, it seems that im missing something, its a simple task, but im having hard time accomplishing that, glad if someone would help
p.s im trying to re-connect the same server machine obviously over and overc.
01/04/2016 20:44 sarkoplata#2
you cannot restart an aborted thread, make sure you create a new instance of it
once you detect the client disconnection, you can simply just start the gateway thread back again.
you shouldn't have any problems with ports if you make sure you dispose everything.
01/04/2016 22:12 Bizzyyyyy#3
just use something like
if (!ag_socket.IsConnected())
{
Globals.MainWindow.Log(" Disconnected from the Agentserver.");

Gateway gw = new Gateway();
gw.Start(textBoxIP.Text, textBoxPort.Text);
...

as sarkoplata already said
01/07/2016 16:34 Isoline*#4
Quote:
Originally Posted by Bizzyyyyy View Post
just use something like
if (!ag_socket.IsConnected())
{
Globals.MainWindow.Log(" Disconnected from the Agentserver.");

Gateway gw = new Gateway();
gw.Start(textBoxIP.Text, textBoxPort.Text);
...

as sarkoplata already said
ok guys thanks, ill try and report back