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
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.
Labels:
c#,
gethostaddress,
ip address,
ipv4,
ipv6,
resolve
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment