using System.Net; using System.Net.Sockets; /*************************************************** Resolve the IPV4 address for a host name. Should work with IP addresses as well. */ IPAddress ipAddress = null; foreach (IPAddress Address in Dns.GetHostAddresses("google.com")) { if (Address.AddressFamily == AddressFamily.InterNetwork) { ipAddress = Address; break; } }
Random stuff that I like to jot down for future reference and to possibly help someone else. If something helped you please drop a comment. Thanks
Showing posts with label ipv6. Show all posts
Showing posts with label ipv6. Show all posts
Thursday, September 12, 2013
C# code to get IPV4 address
Just a code snippet of C# that I'm using to resolve the IPV4 address of a remote server.
Subscribe to:
Posts (Atom)