-
gethostbyname in ping
i'm now writing a program to ping a website
Code:
if((he=gethostbyname("www.yahoo.com"))==NULL)
{
call();
}
]
and i'm using the code above to get the host ip and then send icmp to with another function().
but once the server is unknown i will need to wait for 16 or 17 seconds before the program continue to call(). anyway that i can minimize the waiting time?
i've post to gd before but since i mention bout this c-coding so i think i did better post here. :)
-
you can use signals to make your own timer for it. google for it, as I don't think the faq has info about them, or maybe it does, I'm too lazy to look
-
You could look up asynchronous socket or multithreaded (pthread) programming, and possibly do something else while gethostbyname is executing. I don't think there's much you can do about the delay itself, however, short of getting a faster internet connection.
Beej's socket tutorial: http://lib.daemon.am/Books/BGNET/html/intro.html
-
If using Windows, this thread may help. Obviosly, you would use getaddrinfo rather than getnameinfo.