How to handle a SocketException when there is no internet connection?

I am using Uniweb in order to communicate with my app backend for my iOS app. However, when I have no internet connection, it throws a socket exception as follows:

System.Net.Sockets.SocketException: No such host is known
at System.Net.Dns.hostent_to_IPHostEntry (System.String h_name, System.String h_aliases, System.String h_addrlist) [0x00000] in :0

What is the best way to handle this exception? I tried a try-catch block but it didn’t work. Do I need to modify the source in Uniweb, or is there something I can do to catch this exception in my application code?

I understand this is an old question but I have a suggestion for you that might help other people, I haven’t tried myself yet but I will soon.

try
{
 ......

}
catch (SocketException SE)
{
Debug.Log("ERROR: [" + SE.Message + "]

";);
}