/// <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()}"); } }
/// <summary> /// Resolve endpoint to host:port or return address:port as /// string if resolve fails /// </summary> /// <param name="endpoint"></param> /// <returns></returns> public static string TryResolve(this EndPoint endpoint) { if (endpoint == null) { return(null); } try { return(endpoint.Resolve()); } catch { return($"{endpoint.GetIPAddress()}:{endpoint.GetPort()}"); } }
public void Connect(EndPoint address) { if (address == null) throw new ArgumentNullException("address"); if (_client != null) throw new InvalidOperationException(LocalizedStrings.Str2152); //this.AddInfoLog("BeginConnect"); _client = new TcpClient(); _client.Connect(address.GetHost(), address.GetPort()); _incoming = _client.GetStream(); _outgoing = _client.GetStream(); }
/// <summary> /// Resolve endpoint to host:port or throw. /// </summary> /// <param name="endpoint"></param> /// <returns></returns> public static async Task <string> ResolveAsync(this EndPoint endpoint) { var entry = await endpoint.GetIPAddress().GetHostEntryAsync(); return($"{entry.HostName}:{endpoint.GetPort()}"); }
/// <summary> /// Resolve endpoint to host:port or throw. /// </summary> /// <param name="endpoint"></param> /// <returns></returns> public static string Resolve(this EndPoint endpoint) { var entry = endpoint.GetIPAddress().GetHostEntry(); return($"{entry.HostName}:{endpoint.GetPort()}"); }