Breaking out of functions
I have a program which I am trying to use to detect if there is a temporary disconnect from the internet. If there is then once the connection is detected a function called recovery() is called to set up and initalise things that will have broken. Throughout the recovery function I need to constantly be checking that the connection is still working and has not broken again half way through the recovery process. So what I proposed was something like the code below.
The idea is to start the recovery function from the beginning if at any time a disconnect occurs a second time. However as I understand it, if recovery calls recovery from itself then once the second recovery has finished, then the first recovery will try to continue from where it left off. Therefore I need something in recovery that breaks out of itself and goes back to whatever function called it originally. I considered using break however I believe this only breaks out of the IF statement and not the whole function. Can anyone tell me of a function a bit like Break but that exits the whole function (but not the whole program).
Thankyou in advance for your help,
Chris
Code:
void recovery(void){
//Some other code goes here
if(connected == NULL)
{
recovery();
break;
}
//Insert other code goes in here
if(connected == NULL)
{
recovery();
break;
}
//more code here
//if statement again here etc....
}