Example #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()}");
     }
 }
Example #2
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 string TryResolve(this EndPoint endpoint)
 {
     if (endpoint == null)
     {
         return(null);
     }
     try {
         return(endpoint.Resolve());
     }
     catch {
         return($"{endpoint.GetIPAddress()}:{endpoint.GetPort()}");
     }
 }
Example #3
0
		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();
		}
Example #4
0
        /// <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()}");
        }
Example #5
0
        /// <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()}");
        }