Re: [PLUG] determining my IP address in C

Andrew Bennett on 4 Mar 2004 20:47:02 -0000


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

Re: [PLUG] determining my IP address in C


This may be useful:
http://forums.devshed.com/showpost.php?s=277ee18a1b561309953d987b4b0f23b7&p=413842&postcount=6
It uses if_nameindex() from net/if.h.
-- Andrew
On Wed, 2004年03月03日 at 08:14, Jeff Abrahamson wrote:
> 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. ;-)
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug



AltStyle によって変換されたページ (->オリジナル) /