Thread: gethostbyname in ping

  1. #1
    Registered User
    Join Date
    Nov 2006

    gethostbyname in ping

    i'm now writing a program to ping a website


    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.

  2. #2
    Registered User
    Join Date
    Nov 2006
    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

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    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:

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    If using Windows, this thread may help. Obviosly, you would use getaddrinfo rather than getnameinfo.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ping script doesn't work?
    By userpingz in forum C Programming
    Replies: 3
    Last Post: 05-31-2009, 07:53 PM
  2. Replies: 8
    Last Post: 05-07-2009, 11:31 AM
  3. IPv6 ping in windows...problem..lots of ode:(
    By Neill KElly in forum C Programming
    Replies: 3
    Last Post: 04-27-2009, 11:50 PM
  4. ping client
    By cpp_is_fun in forum C Programming
    Replies: 4
    Last Post: 11-29-2006, 12:44 PM
  5. Ping
    By ZakkWylde969 in forum Tech Board
    Replies: 5
    Last Post: 09-23-2003, 12:28 PM