LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
 
Search this Thread
Old 04-07-2005, 01:07 AM   #1
galaxier
LQ Newbie
 
Registered: Apr 2005
Location: China
Posts: 2

Rep: Reputation: 0
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
 
Old 04-08-2005, 10:01 AM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
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.
 
Old 04-08-2005, 10:03 AM   #3
Darin
Senior Member
 
Registered: Jan 2003
Location: Portland, OR USA
Distribution: Slackware, SLAX, Gentoo, RH/Fedora
Posts: 1,024

Rep: Reputation: 45
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.
 
Old 04-08-2005, 10:04 AM   #4
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
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 */
              }
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sendmail and gethostbyaddr mikz Linux - General 1 03-20-2005 08:05 PM
what are the Hexadecimal function and ASCII function in Perl Bassam Programming 1 06-03-2004 01:44 AM
A main can be changed by a function local without passing anything to the function? ananthbv Programming 10 05-04-2004 01:31 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM
Getting hostname of remote machine with gethostbyaddr() thomjakub Linux - Networking 4 03-06-2004 09:08 AM


All times are GMT -5. The time now is 06:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration