CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 1999
    Posts
    6

    how to get the host ip

    when i connect to internet through dial,
    how can i get the host's ip address


  2. #2
    Guest

    Re: how to get the host ip

    I don't know if you want know yourself address when you connect on ppp and achive a ip address.
    you can input
    "route print"
    under dos window.


  3. #3
    Join Date
    Oct 1999
    Posts
    6

    Re: how to get the host ip

    thanks a lot,
    can you teach how to get it through c code


  4. #4
    Join Date
    Oct 1999
    Location
    Germany
    Posts
    238

    Re: how to get the host ip

    Hi !

    try using gethostname(*) which fills a buffer with the name
    of the local host.
    Once you have the name, use gethostbyname(*) which
    returns a pointer to a HOSTENT structure.
    Next to other things this structure contains a list of
    IP-addresses used by the host specified in the
    call to gethostbyname.
    if your computer is not part of an ip-network it should
    only return the ip-address given to you by your provider.

    regards,

    Matthias.



  5. #5
    Join Date
    Oct 1999
    Posts
    6

    Re: how to get the host ip

    thank you a lot,
    and can you teach me how to get the ISP's ip address?


  6. #6
    Join Date
    Oct 1999
    Location
    Germany
    Posts
    238

    Re: how to get the host ip

    Hi again !

    for what you want to do I think you need to get a bit deeper into the internals
    of TCP/IP.
    TCP/IP supports numerous options which you can fill in the header of
    a TCP/IP-packet. One of these options lets you record the route that
    a packet takes from a source host to a destination host. The IP-addresses
    of all hosts along the route of the paket are actually written to the header
    of the packet ( the header's length is not fixed ). The problem with
    this option is that it's not supported by all IP-stacks ( that's what I know ).
    Take a look at the RFCs for TCP/IP to get to the details.

    Regards,

    Matthias.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured