Leo1906 Posted May 15, 2017 Share Posted May 15, 2017 (edited) Hi there I am trying to check wether a certain host is online or not. So far I just used Ping to do so. Since Ping needs at least the time specified in timeout if a host is unreachable, I was wondering if the same could be done with TCPNameToIP()? For me it seems that this function is a lot quicker checking a host. If the name can't be translated to an IP it throws an error. So if the host is unreachable I should get an error .. right? The bad thing about Ping is that the Thread is blocked until the timeout is reached (in case of an unreachable host). This wont happen if you use TCPNameToIP(). So are my thoughts correct? I don't need the detailed informations Ping returns, only if the host is online or offline .. Edit: or does TCPNameToIP() also uses local cached DNS -systems? So that it remembers the Name to IP conversion in one Windows session? But even this won't be that bad .. Edited May 15, 2017 by Leo1906 Link to comment Share on other sites More sharing options...
orbs Posted May 15, 2017 Share Posted May 15, 2017 by using TCPNameToIP() you are actually trying to check host status by querying the DNS service. this is obviously wrong. a DNS service maintains a DNS record even when the host is not alive for a while. and it does not bother to check the host in order to reply to a DNS query. to check if a host is online, you must check if the host is online, not if the DNS service is online. use ping for the simplest test, and if the host is configured to ignore ping (for security reasons), you can alternatively check a vital service that the host provides. Skysnake 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Leo1906 Posted May 16, 2017 Author Share Posted May 16, 2017 Ok but then TCPNameToIP() could be used to check the internet connection in general ..? Link to comment Share on other sites More sharing options...
spudw2k Posted May 16, 2017 Share Posted May 16, 2017 (edited) Ping is still probably the best better option. You could have live DNS servers which will resolve hostnames/IPs, but the destination host still be offline. Edited May 16, 2017 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
jguinch Posted May 16, 2017 Share Posted May 16, 2017 TCPNameToIP resolves the host name with a DNS query. A DNS resolution does not require an internet connection : so, no, TCPNameToIP cannot be used to check the Internet connection. Look at InternetGetConnectedState here : https://www.autoitscript.com/wiki/Connected, it's a sure way Skysnake 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now