You create a client inside loop(). When loop() exits, client goes out of scope so it stopped. You probably want client to be global and then depending on whether or not it is connected, check for data or get a new client
countrypaul:
Since loop neer exits not sure how the clinet can go out of scope.
However since the loop never exits everytime it comes round the old client will be left hanging anf a new client created.
So I disagree on the cause, but agree on the solution, make client global and initialise it in setup.
Your understanding of setup() and loop() are not accurate. The arduino main() program basically does
int main() {
setup();
while(1) {
loop();
SerialEvent();
}
}
So loop() most definitely terminates and main calls it again. This most definitely triggers all local variables to go out of scope and depending on the object, the destructor will be called. [I didn't look at that particular class so can't comment on 'client']
Blh64 - Sorry, I have no idea why I wrote that, clearly completely wrong, even if loop never exited it would be completely wrong since that scope would end at the } regardless.