| | |
| | | { |
| | | try |
| | | { |
| | | localIpep = new IPEndPoint(IPAddress.Parse("192.168.2.111"), 53470); // 本机IP和监听端口号 |
| | | var config = Helpers.Tool.GetSystemConfig().baseSysConfg; |
| | | var ipConfig = "127.0.0.1"; |
| | | var portConfig = 53470; |
| | | var toIp = "255.255.255.255"; |
| | | var toPort = 53490; |
| | | if (config != null) |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(config.sendIp)) |
| | | { |
| | | ipConfig = config.sendIp; |
| | | } |
| | | if (!string.IsNullOrWhiteSpace(config.sendPort)) |
| | | { |
| | | int.TryParse(config.sendPort, out portConfig); |
| | | } |
| | | if (!string.IsNullOrWhiteSpace(config.toIp)) |
| | | { |
| | | toIp = config.toIp; |
| | | } |
| | | if (!string.IsNullOrWhiteSpace(config.toPort)) |
| | | { |
| | | int.TryParse(config.toPort, out toPort); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ipConfig = "127.0.0.1"; |
| | | } |
| | | localIpep = new IPEndPoint(IPAddress.Parse(ipConfig), portConfig); // 本机IP和监听端口号 |
| | | |
| | | udpcSend = new UdpClient(localIpep); |
| | | |
| | | byte[] sendbytes = data; |
| | | IPEndPoint remoteIpep = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 53490); // 发送到的IP地址和端口号 |
| | | IPEndPoint remoteIpep = new IPEndPoint(IPAddress.Parse(toIp), toPort); // 发送到的IP地址和端口号 |
| | | string str = ""; |
| | | foreach (var a in sendbytes) |
| | | { |