![](wink.gif)
How to eliminate delay when looking up IPs?
When I call gethostbyname() with an address that doesn''t exist it takes about 15-20 seconds to return. Is there a socket option or some other way to fix this?
If the user accidentally misenters the IP they would have to wait for 15 seconds for this function to return. I was thinking about spawning a separate thread and putting this call into it.
Also, is there a way to cut off gethostbyname() if its taking too long? Sometimes it takes long and lags me. If I''m not connected to the internet sometimes it takes 3 seconds to discover that fact.
Thanks (in advance) for answers
![](wink.gif)
if they are entering ip addresses you dont use gethostbyname() since you dont need to do the look up. therefore get rid of gethostbyname() unless you want to allow domain names to entered as well (not needed, but nice). just make sure your code is smart and does not try using gethostbyname() on ip address.
You could consider using WinSock''s WSAAsyncGetHostByName() function. It sends your window procedure a message when it completes. This won''t get rid of the delay, but it will allow your application to do other stuff while you''re waiting. You can also use the WSACancelAsyncRequest() function if you think the host lookup is taking too long.
Matt
Matt
Matt
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement