Sunday, May 02, 2010

Only return first IP which is IP4


// This is separate as we need to encapsulate more than FCL offers us
// It is here so it is reusable by all
// It only returns the first IP, that is by design. If you want the full
// list, use the FCL methods directly.
protected IPAddress ResolveAddress(string aAddress) {
IPHostEntry xIP = Dns.GetHostEntry(aAddress);
// Some host names (ie localhost) can return mult entries
// For now we want the first IP4 one, which is not always in [0]
return xIP.AddressList.First(x => x.AddressFamily == AddressFamily.InterNetwork);
}

No comments:

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge