Checking for the Internet before accessing the Internet data is the right way to do in any app that you make in any platform.
Here is a small gist to make the network check on Corona SDK. Either use the code in the same Lua file you use or use a separate utility lua file to add the functions. Check here for making the Utility file in Corona SDK (Lua).
In the function where you want to check for the utility, just call the function, which will return you the network status.
Code Explanation :
1 — create a local variable.
2 — Create a network listener function available in the network library. Note that this will work only on iOS, so we are using sockets for Android.
3 — we are checking for the Platform and if its iOS, we are sending the status using the network listener which automatically changes the value of the isNetworkAvailable variable.
4 — Using the Sockets to check the internet connection if the platform is Android.
5 — Based on the Socket test result, we are setting the value for the isNetworkAvailable variable.
6 — Close the test connection
7 — return the isNetworkAvailable Variable.
That's for the Network. Happy coding!