when i connect to internet through dial,
how can i get the host's ip address
Printable View
when i connect to internet through dial,
how can i get the host's ip address
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.
thanks a lot,
can you teach how to get it through c code
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.
thank you a lot,
and can you teach me how to get the ISP's ip address?
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.