I am working with socket communication in Arduino, and I need the try/catch block for proper handling, what do you guys suggest? My search on the internet wasn't successful.
edit:
The code I am working with uses the WiFly module to interact with a mobile application, I am building a robot module with some controls over mobile application using Android. Everything works just fine, but sometimes the socket gets disconnected, so I need to add handling for such cases, something similar to try/catch block, but I didn't find similar block for Arduino.
My code:
void loop() {
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
// Serial.print("client connected \n");
char c = client.read();
if(c == 'L')
turnLeft();
if(c == 'R')
turnRight();
if(c == 'F')
goForward();
if(c == 'B')
goBackward();
if(c == 'S')
Stop();
Serial.print(c);
}
}
// give the web browser time to receive the data
delay(100);
client.stop();
}
}