110,549
社区成员
发帖
与我相关
我的任务
分享
//当前要测试的单词数组下标
public static int iCurTestWordIndex;
public static string strLocalHAddr;
public static IPEndPoint SearchServeripEP;
public static int sendDataLen;
public static byte[] udpRecvDataBuf;
public static byte[] udpDataSendBuf;
public static ManualResetEvent mrEventGotServer;
public static ManualResetEvent mrEventTermiThread;
public static void workThread()
{
#region 获取本地可用IP地址
strLocalHAddr = null;
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
//检测可用网卡网关值,确定是否可用
NetworkInterface[] NetWorkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach(NetworkInterface NetworkIntf in NetWorkInterfaces)
{
IPInterfaceProperties IpInterPro = NetworkIntf.GetIPProperties();
UnicastIPAddressInformationCollection uniIPAInfoCol = IpInterPro.UnicastAddresses;
foreach(UnicastIPAddressInformation UniCIPAInfo in uniIPAInfoCol)
{
if((UniCIPAInfo.Address.AddressFamily==AddressFamily.InterNetwork)
&& (UniCIPAInfo.IPv4Mask!=null))
{
if(IpInterPro.GatewayAddresses[0].Address.ToString().CompareTo("0.0.0.0")!=0)
{
strLocalHAddr = UniCIPAInfo.Address.ToString();
break;
}
}
}
}
Gatewayaddresses 中不存在数据。