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. > > Any ideas?
Warning: This is completely tongue in cheek. :)
How about this?
fh = popen("/sbin/ifconfig eth0", "r");
/* Then just fread/fgets from fh to find the IP */
pclose(fh);
Lotta overhead to find the IP, I know. ;-)
--
[EMAIL PROTECTED] is Doran L. Barton, president/CTO, Iodynamics LLC
Iodynamics: IT and Web services by Linux/Open Source specialists
"The Civil War began in 1830. Many soldiers repeatedly gave their lives
for their country. "
-- Seen in a school report
begin:vcard fn:Doran Barton n:Barton;Doran org:Iodynamics adr:;;PO Box 411;Logan;UT;84323;USA email;internet:[EMAIL PROTECTED] title:President tel;work:801-413-1572 tel;cell:801-520-9875 x-mozilla-html:FALSE url:http://www.iodynamics.com/ version:2.1 end:vcard
signature.asc
Description: OpenPGP digital signature
/* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
