Thread: using gethostbyname , getaddrinfo & WSAAsyncGetHostByName

  1. #1
    Registered User
    Join Date
    Mar 2004

    using gethostbyname , getaddrinfo & WSAAsyncGetHostByName

    basically these 3 functions retrieve address info of the remote computer so that the info can be passed to other functions like connect or sendto

    what i want to do is a client that broadcasts UDP packets to all my computers on my network installed with a custom server .

    now i feel that gethostbyname is the worst one to use because it blocks and freezes the client.

    WSAAsyncGetHostByName doesnt block but is not designed to provide parallel resolution of several names. especially it's callback message doesnt even have the host info in it's lParam or WParam.

    i dont really know much about getaddrinfo but i am guessing it is the ideal function for my program

    but all my computers are on win98 only as says winxp must be used.

    any suggestions on what i should do??

  2. #2
    sockets mad
    Join Date
    Mar 2002
    Depending on your programs requirements, multicast might be a better idea that connecting to them all individually. This would mean you can 'broadcast' packets to a range of addresses on your network, and any that are listening will pick it up.

    I know next to nothing about multicast, but I'm sure some people around here do and would be willing to help. Have a look around the net and see what you can find.


  3. #3
    sockets mad
    Join Date
    Mar 2002
    If this turns out not to be useful, you could always have your gethostbyname() resolutions executing in another thread, so that your program remains responsive while it is resolving the hostnames.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getaddrinfo()
    By Cactus_Hugger in forum Windows Programming
    Replies: 1
    Last Post: 07-24-2006, 02:41 AM
  2. gethostbyname allways NULL
    By BianConiglio in forum Windows Programming
    Replies: 6
    Last Post: 08-18-2005, 01:27 AM
  3. Replies: 1
    Last Post: 09-11-2004, 08:52 AM
  4. WinSock and gethostbyname() won't return correctly...
    By SyntaxBubble in forum C++ Programming
    Replies: 2
    Last Post: 07-05-2002, 12:08 PM
  5. Resolving Hostname Using getaddrinfo(...) :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 1
    Last Post: 05-03-2002, 08:35 PM