Jeff Abrahamson on 3 Mar 2004 13:21:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] determining my IP address in C


I want to determine my own IP address.

A kludgy way is to bind to a high port, send myself (on 127.0.0.1) a
packet containing only a long random number, and look at the from
address.  Even then I might see 127.0.0.1, though.

I bet there's a better way.  Anyone know?

If the box has multiple interfaces, the above fails.  Is their a way
to get all the addresses that are me?

Solutions involving parsing the output of popen("/sbin/ifconfig") will
not be considered. ;-)

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>
 GPG fingerprint: 1A1A BA95 D082 A558 A276  63C6 16BF 8C4C 0D1D AE4B

Attachment: signature.asc
Description: Digital signature