LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   what's the matter with the function gethostbyaddr() (https://www.linuxquestions.org/questions/programming-9/whats-the-matter-with-the-function-gethostbyaddr-310614/)

galaxier 04-07-2005 01:07 AM

what's the matter with the function gethostbyaddr()
 
I am a new comer with linux.when i begin my network programming on
linux,i find the function gethostbyaddr() can't work well.It always return NULL in the ethernet.the error is ether HOST_NOT_FOUND OR TRY_AGAIN
however when i programs on windows the function works well.who can help me out .THANKS

jtshaw 04-08-2005 10:01 AM

I'm moving this thread to programming, since it seams to best apply there. Please don't post duplicate posts in multiple sections of the forum.

Darin 04-08-2005 10:03 AM

http://www.linuxquestions.org/questi...hreadid=310621

For starters, please don't double post, it's against the rules:

-from http://www.linuxquestions.org/questions/register.php (ok that URL doesnt show the terms if you are already signed in, but you did have to accept them when you made an account to post)
Quote:

# Do not post the same discussion in more than one forum. Duplicate discussions can be frustrating for other members. Try and pick the most relevant forum for your post. If you are unsure put it in Linux - General.
The question you asked here and in software is best answered in
Programming (This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.)

If your question does not get moved there by a moderator, wait 24 hours and then post it in that forum. The software and network forums are for user questions and not as many programmers look in them.

jtshaw 04-08-2005 10:04 AM

Now.. on to your problem, how are you calling the function? The gethostbyaddr function in Linux returns a struct hostent.. which looks like this:

Code:

struct hostent {
                      char    *h_name;        /* official name of host */
                      char    **h_aliases;    /* alias list */
                      int    h_addrtype;    /* host address type */
                      int    h_length;      /* length of address */
                      char    **h_addr_list;  /* list of addresses */
              }



All times are GMT -5. The time now is 07:28 PM.