LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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-27-2005, 05:32 AM   #1
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Rep: Reputation: 30
reverse DNS in C?


hiho@ll

i just wrote a server who needs to make a RDNS to get the hostname of the ip who just connected to my server
anybody knows a C-function or a prog, which could do this for me?

thx@ll
 
Old 04-27-2005, 05:56 AM   #2
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
i'm not a programmer, but from what i googled i think what you want might be:

Code:
gethostbyaddr()
just my two cents...



BTW, i've asked a moderator to move your thread to the programming forum so that it will be more exposed to programmers...

 
Old 04-27-2005, 12:53 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 04-27-2005, 01:05 PM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
I've used this in a program to do that:
Code:
char *ip_to_hostname(char *hostname)
{
  struct hostent *hent;
  struct in_addr addr;

  if(!inet_aton(hostname, &addr))
    return(hostname);

  if((hent = gethostbyaddr((char *)&(addr.s_addr), sizeof(addr.s_addr),
    AF_INET)))
  {
    strcpy(hostname, hent->h_name);
  }

  return(hostname);
}
hostname would initially hold the IP address.
 
  


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
No reverse DNS??? DragonM15 Linux - Networking 5 11-22-2005 01:06 AM
Reverse DNS Webbie Linux - Networking 4 10-10-2005 08:49 PM
Reverse DNS Snerkel Linux - Networking 11 04-19-2005 01:25 PM
Reverse DNS davespink Linux - Networking 2 02-27-2005 07:44 PM
Reverse DNS Pyro2k4 Linux - Networking 8 09-06-2004 05:59 PM


All times are GMT -5. The time now is 08:35 PM.

Main Menu
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