현재 실행중인 프로그램이 돌아가고 있는 컴퓨터의 아이피를 가져 온다.
using System;
using System.Net;
using System.Net.Sockets;
namespace SelfHost
{
class Program
{
static void Main(string[] args)
{
string url = Client_IP;
Console.WriteLine("This ip : {0}", url);
Console.ReadLine();
}
public static string Client_IP
{
get
{
IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
string ClientIP = string.Empty;
for (int i = 0; i < host.AddressList.Length; i++)
{
if (host.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
{
ClientIP = host.AddressList[i].ToString();
}
}
return ClientIP;
}
}
}
}
이렇게 소스를 등록하고 "Client_IP" 를 호촐하면 아이피를 가져 온다.

