This HostResolve procedure runs on a thread separately, to not interrupt other working functions. I would like to ask here if this procedure is correctly written or not?Any recommendations and improvements, if any one willing to help?Procedure HostResolve();   const   URL : array[1..4] of String =('facebook.com', 'google.com', 'yahoo.com', 'gmail.com');   var      IP:String;      IsConnected:Boolean;      i:integer;   begin      IsConnected := false;      While true do      begin        if IsConnectedToInternet then          begin           if IsConnected = false then             begin        //          for  i := Low(URL) to High(URL) do            begin              if  HostToIp(URL[i], IP) then               begin                 ShowMessage(IP);                 IsConnected := true;                 Break;               end;            end;        //        end;      end else begin          IsConnected := false;      end;        Sleep(1000);    end; end; Function IsConnectedToInternet: Boolean; var  dwConnectionTypes: DWORD;   begin    dwConnectionTypes :=    INTERNET_CONNECTION_MODEM +    INTERNET_CONNECTION_LAN +    INTERNET_CONNECTION_PROXY;    Result := InternetGetConnectedState(@dwConnectionTypes, 0);  end;Function HostToIP(sHost: string; var sIP: string):Boolean;var  aHostName: array[0..255] of Char;  pcAddr   : PChar;  HostEnt  : PHostEnt;  wsData   : TWSAData;begin  WSAStartup($0101, wsData);  try    GetHostName(aHostName, SizeOf(aHostName));    StrPCopy(aHostName, sHost);    hostEnt := GetHostByName(aHostName);    if Assigned(HostEnt) then      if Assigned(HostEnt^.H_Addr_List) then begin        pcAddr := HostEnt^.H_Addr_List^;        if Assigned(pcAddr) then begin          sIP := Format('%d.%d.%d.%d', [Byte(pcAddr[0]), Byte(pcAddr[1]),            Byte(pcAddr[2]), Byte(pcAddr[3])]);          Result := True;        end else          Result := False;      end else        Result := False    else begin      Result := False;    end;  finally    WSACleanup;  end;end;
Internet Connectivty and Resolve host
delphi