111,097
社区成员




string hostName = Dns.GetHostName();//本机名
IPHostEntry localhost = Dns.GetHostByName(hostName);
string ip = localhost.AddressList[0].ToString();
localaddr = IPAddress.Parse(ip);
// 实名发送
localIpep = new IPEndPoint(localaddr, 1501); // 本机IP,指定的端口号
udpcSend = new UdpClient(localIpep);
remoteIpep = new IPEndPoint(IPAddress.Parse(Info.RemoteIP), 1500);//终端ip和port
udpcSend.Send(data, data.Length, remoteIpep);
udpcSend.Close();
udpcRecv = new UdpClient(new IPEndPoint(localaddr, 1501));
IPEndPoint remoteIpep = new IPEndPoint(IPAddress.Any, 0);
byte[] bytRecv = udpcRecv.Receive(ref remoteIpep);
try{
udpcRecv = new UdpClient(new IPEndPoint(localaddr, 1501));
IPEndPoint remoteIpep = new IPEndPoint(IPAddress.Any, 0);
byte[] bytRecv = udpcRecv.Receive(ref remoteIpep)
}ca...