[erlang-questions] : : : Finding IP addresses in a PC

Raimo Niskanen raimo+erlang-questions@REDACTED
Thu Oct 5 09:19:50 CEST 2006


The current implementation uses
    WSAIoctl(..., SIO_GET_INTERFACE_LIST, ...)
are there any particular backdraws with it.

The interface today has got inet:getiflist() that
returns a list of interface names; on a typical linux box
-> {ok,["eth0","lo0"]}, and then inet:ifget("lo0", [addr])
-> {ok,[{addr,{127,0,0,1}]}.

It seems to me more logical that inet:getiflist() on
Windows returns a list of adapter names, that can be 
used as arguments to inet:ifget(). Today the adapter
names on windows are generated as the IPv4 address string
of the adapter, but they should probably be the "real" 
adapter names (are they as clumsy as 
"Eternet adapter Local Area Connection 1"?).

That might be an argument for using GetAdaptersInfo.
Are there any more?

On Wed, Oct 04, 2006 at 05:12:57PM +0100, David Hopwood wrote:
> David Hopwood wrote:
> > If you use GetAdaptersInfo, the string formatting is done for you in
> > the IpAddress.String field:
> > 
> >   IP_ADAPTER_INFO dummy;
> >   DWORD len = 0;
> >   if (GetAdaptersInfo(&dummy, &len) != ERROR_BUFFER_OVERFLOW || len == 0) {
> >       return FAILED;
> >   }
> > 
> >   IP_ADAPTER_INFO pAdapters = (IP_ADAPTER_INFO *) malloc(len);
> 
> IP_ADAPTER_INFO *pAdapters = ...
> 
> -- 
> David Hopwood <david.nospam.hopwood@REDACTED>
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list