public string GetLocalIPStr()
{
string localIP = string.Empty;
using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0))
{
socket.Connect("8.8.8.8", 65530);
IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint;
localIP = endPoint.Address.ToString();
}
return localIP;
}
标签:endPoint,socket,C#,IP,localIP,本地,Socket,string
From: https://www.cnblogs.com/huvjie/p/16968699.html