On Tue, Jan 16, 2007 at 09:22:36PM -0700, Topher Fischer wrote: > Is there a "standard" (de facto or otherwise) way of finding a local > machine's IP address in C? I've googled about, but I still haven't > found what I'm looking for. The only thing I've come up with so far is > calling gethostbyname on my machine's hostname, but that obviously won't > work when I leave my home network.
One way to do it would be to use the SIOCGIFCONF ioctl on a socket. That should give you back all the interfaces and at least their IP address. This works for sure on linux, not so sure about other flavors of *nix. If you care about those you'll probably want to strace/truss/ktrace ifconfig to see how it gets the information. -- Byron Clark
signature.asc
Description: Digital signature
/* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
