using gethostbyname , getaddrinfo & WSAAsyncGetHostByName

This is a discussion on using gethostbyname , getaddrinfo & WSAAsyncGetHostByName within the Networking/Device Communication forums, part of the General Programming Boards category; basically these 3 functions retrieve address info of the remote computer so that the info can be passed to other ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    114

    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 http://msdn.microsoft.com/library/de...addrinfo_2.asp says winxp must be used.

    any suggestions on what i should do??

  2. #2
    sockets mad
    Join Date
    Mar 2002
    Posts
    126
    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.

    Dan

  3. #3
    sockets mad
    Join Date
    Mar 2002
    Posts
    126
    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, 03:41 AM
  2. gethostbyname allways NULL
    By BianConiglio in forum Windows Programming
    Replies: 6
    Last Post: 08-18-2005, 02:27 AM
  3. Replies: 1
    Last Post: 09-11-2004, 09:52 AM
  4. WinSock and gethostbyname() won't return correctly...
    By SyntaxBubble in forum C++ Programming
    Replies: 2
    Last Post: 07-05-2002, 01:08 PM
  5. Resolving Hostname Using getaddrinfo(...) :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 1
    Last Post: 05-03-2002, 09:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21