コード例 #1
0
 /// <summary>
 /// Resolve endpoint to host:port or return address:port as
 /// string if resolve fails
 /// </summary>
 /// <param name="endpoint"></param>
 /// <returns></returns>
 public static async Task <string> TryResolveAsync(this EndPoint endpoint)
 {
     if (endpoint == null)
     {
         return(null);
     }
     try {
         return(await endpoint.ResolveAsync());
     }
     catch {
         return($"{endpoint.GetIPAddress()}:{endpoint.GetPort()}");
     }
 }