×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: C#
Posted by: user7784c
Added: May 22, 2017 6:58 PM
Views: 6
Tags: ip
Recuperar de una máquina cliente la IP
  1.         /// <summary>
  2.         /// Obtenemos la ipv4 e ipv6 de la máquina cliente.
  3.         /// </summary>
  4.         /// <returns>String[]
  5.         /// string[0] = ipv6 y string[1] = ipv4
  6.         /// </returns>
  7.         public string[] ObtenerIP()
  8.         {
  9.             string[] myip;
  10.             System.Net.IPAddress[] localIPs = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName());
  11.             myip = new string[] { localIPs[0].ToString(), localIPs[1].ToString() };
  12.             return myip;
  13.         }