private void Form1_Load(object sender, EventArgs e)//初始化为UDP Server模式
{
cobProtocol.SelectedIndex = 0;
txtIP.Text = GetAddressIP();
Control.CheckForIllegalCrossThreadCalls = false;
}
string GetAddressIP()
{
string AddressIP = "";
foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
{
if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
{
AddressIP = _IPAddress.ToString();
ip = _IPAddress;//设定全局的IP
}
}
return AddressIP;
}
private void btnStart_Click(object sender, EventArgs e)//设置目标IP(Client),本地IP(Server)
1