static internal IPEndPoint ConstructEndPoint(IPHostEntry host, int port)
{
if(0 >= host.AddressList.Length)
{
NSTrace.WriteLineError("Provided host structure do not contains addresses.");
throw new ArgumentException("Provided host structure do not contains addresses.", "host");
}
foreach (var addr in host.AddressList)
{
if (addr.AddressFamily == AddressFamily.InterNetwork)
return new IPEndPoint(addr, port);
}
return new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
}