Erlang futures

Klacke klacke@REDACTED
Thu Apr 19 09:45:11 CEST 2001


On Wed, Apr 18, 2001 at 10:36:11PM +0200, Magnus Ahltorp wrote:
> How can I get a list of the IP addresses on the machine the node is
> running on? There are two drivers named udp_inet and tcp_inet that
> seem to return that when INET_REQ_IFGET is requested.
> 
> Is this the correct way? In that case, how do I call this driver? If
> not, how do I get the list?
> 


-module(a).
-author('klacke@REDACTED').
-include_lib("kernel/include/inet.hrl").

-compile(export_all).

ips() ->
    {ok, Name} = inet:gethostname(),
    {ok, HE} = inet:gethostbyname(Name),
    HE#hostent.h_addr_list.



This of cource only returns info from the configured
name service.

The call inet:getif() will query the driver the way you
want and return a list of {IP, Bcast, Mask} tuples



/klacke


-- 
Claes Wikstrom                        -- Caps lock is nowhere and
Alteon WebSystems                     -- everything is under control          
http://www.bluetail.com/~klacke       --




More information about the erlang-questions mailing list