[oclug] [OT] C: get local ip?

James Leigh james.leigh at ottawa.com
Tue Mar 19 17:02:15 EST 2002


On Tue, 2002-03-19 at 15:48, David F. Skoll wrote:
> There is no easy way to do what you want in C.  Basically, you
> have to go through the routing table to find out which interface
> is used for the default route, and then use ioctl's to get its IP
> address.  There are some complications:

what about getting the hostname then doing a reverse lookup,  that
should work on machine that only have one interface (other then lo).  If
so, what would I get the hostname?

james





More information about the OCLUG mailing list