[erlang-questions] how to get the factual ip address?

Alex Alvarez eeajam@REDACTED
Wed Oct 29 09:22:02 CET 2008


getif/0 and getiflist/0 seem very useful, but shouldn't their output be in
sync order-wise with each other?

getif/0 in my machine outputs...

{ok,[{{192,168,1,3},{192,168,1,255},{255,255,255,0}},
     {{127,0,0,1},{0,0,0,0},{255,0,0,0}}]}

, while getiflist/0 outputs...

{ok,["lo","eth0"]}


This might be a problem if you had several more interfaces available.
Knowing the output of both are always in sync might simplify things out.


Cheers, Alex



>Computers have more than one IP address.  E.g., yours has both
>127.0.0.1 <http://127.0.0.1/> and 192.168.1.101.  Other computers have even
more.  The
>inet module has undocumented functions getif/0 and getiflist/0 that
>might do what you want.
>
>Another possibility is to call inet:sockname/1 on an open socket to
>find what address the operating system used.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081029/7f261e77/attachment.htm>


More information about the erlang-questions mailing list