linux tcp/ip: How to reverse resolve a hostname from an ip address?

Discussion in 'C++' started by Tim Veldhuizen, Jul 22, 2003.

  1. Hi all!

    I'm attempting at writing a networked program. It is going to be a threaded
    irc server in c++ using almost nothing but oop code.
    And it needs to know the full hostname of the users that connect to it. I
    already get some info from this code:

    workersock = accept(mastersock, &sockaddr, &addrlen);
    printf("Received a Client Connection from: %s port: %d fd: %d\n",
    inet_ntoa(sockaddr.sin_addr), ntohs(sockaddr.sin_port), workersock);

    But it also needs to get the hostname resolved.. Something like 127.0.0.1
    would resolve to localhost.localdomain but for every possible ip (if there
    is a dns that knows the hostname ofcourse)
    I don't mind if the command or routine would take some time, becouse it is
    going to work from within a thread either way.. (It would have to be thread
    safe too then i guess)
    I've searched google for it and looked through some groups, but can't seem
    to find it.

    Any help is more than welcome. Tnx in advance..

    Tim.
     
    Tim Veldhuizen, Jul 22, 2003
    #1
    1. Advertising

  2. Re: Solved (linux tcp/ip: How to reverse resolve a hostname from an ip address?)

    >> irc server in c++ using almost nothing but oop code.

    >> printf("Received a Client Connection from: %s port: %d fd: %d\n",
    >> inet_ntoa(sockaddr.sin_addr), ntohs(sockaddr.sin_port), workersock);


    Hmm???

    Jonathan
     
    Jonathan Mcdougall, Jul 24, 2003
    #2
    1. Advertising

  3. Re: Solved (linux tcp/ip: How to reverse resolve a hostname from an ip address?)

    "Jonathan Mcdougall" <> wrote in message
    news:...
    > >> irc server in c++ using almost nothing but oop code.

    >
    > >> printf("Received a Client Connection from: %s port: %d fd: %d\n",
    > >> inet_ntoa(sockaddr.sin_addr), ntohs(sockaddr.sin_port), workersock);

    >
    > Hmm???
    >
    > Jonathan


    i said almost.. ;D
    I kinda like printf much better than cout.. If that was what you meant.. :)

    Tim.
     
    Tim Veldhuizen, Jul 24, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AWieminer
    Replies:
    0
    Views:
    768
    AWieminer
    Jul 12, 2005
  2. vi
    Replies:
    5
    Views:
    16,883
    Roedy Green
    Sep 19, 2005
  3. Mike Kansky

    DNS Resolve IP to HostName

    Mike Kansky, Jun 6, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    5,063
    Mike Kansky
    Jun 6, 2006
  4. dxuranus
    Replies:
    6
    Views:
    4,367
    dxuranus
    Jul 27, 2006
  5. Replies:
    1
    Views:
    10,310
Loading...

Share This Page