how to get the DNS hostname?

This is a discussion on how to get the DNS hostname? within the C Programming forums, part of the General Programming Boards category; when i type "hostname" in the command line I get something like 2.x.aaa.bbb.in-addr.arpa I wonder if there is a function ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126

    how to get the DNS hostname?

    when i type "hostname" in the command line I get something like 2.x.aaa.bbb.in-addr.arpa
    I wonder if there is a function that returns that value...
    (I have tried with gethostname() but it only returns me 2.x.a , which is incomplete)
    Mac OS 10.6 Snow Leopard : Darwin

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    well, assuming your program is going to be UNIX-only, check the man page for hostname. you will see in the explanation that all it does, pretty much, is read from a file and prints it. what you can do is read from that same file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I get the Hostname in Java?
    By cpjust in forum Tech Board
    Replies: 9
    Last Post: 02-07-2009, 11:13 AM
  2. DNS issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 08-02-2008, 10:15 AM
  3. DNS & Mail settings modifier
    By DemonSoul in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 05-20-2004, 12:43 PM
  4. Resolving Hostname :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-08-2002, 08:26 AM

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