How can i find my LAN IP Address using std.socket?
Vladimir Panteleev
vladimir at thecybershadow.net
Tue Feb 4 07:48:49 PST 2014
On Tuesday, 4 February 2014 at 13:02:26 UTC, TheFlyingFiddle
wrote:
> I'm trying to find my own ip address using std.socket with
> little success. How would i go about doing this? (It should be
> a AddressFamily.INET socket)
This program will print all of your computer's IP addresses:
import std.socket;
import std.stdio;
void main()
{
foreach (addr; getAddress(Socket.hostName))
writeln(addr.toAddrString());
}
This includes IPv6 addresses. You can filter the address family
by checking addr's addressFamily property.
More information about the Digitalmars-d-learn
mailing list