Quote:
System.StackOverFlowException is here after 100 loops
That isn't a loop: it's a recursive call.
So each time you call
RemoteConnect
it takes a bit more stack space - and it's not massive to start with - so at some point it will run out of stack and you get an overflow exception.
There is no good reason for that code to be recursive: a simple loop would be both more obvious and efficient.
And move local variables into the method they are used in - it's pointless having them at class level if they are only accessed or relevant in a single method!