使用C#检测ip冲突
有没有办法检测消息IP冲突?我将在我的程序的线程中使用它。
Is there any way to detect the message IP conflict? I will be using this in a thread in my program.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的问题是定位警报窗口,提示网络上存在重复的 IP,我建议您使用 API 枚举所有窗口并查看警报窗口是否存在。
您可以借助 Visual Studio 工具 Spy++ 来查看窗口的特征。
If your problem is locating the alert window saying there is a duplicate IP on the network, I suggest your use the API to enumerate all windows and see if the alert window is there.
You may be helped by Visual Studio tool Spy++ to see the characteritics of the window.
这个问题不是特别精确和老旧,但无论如何我都会尝试一下,因为我想知道我能对这些问题做些什么,因为我正在编写一个应用程序来操纵 PC 上的 IP 地址,以便启动依赖于具体地址。
如果其他人有同样的问题,我建议首先尝试避免任何冲突。
问题是,设置 IP 地址是一项管理任务,只能由知道自己在做什么的人“徒手”完成。如果您通过代码设置 IP 地址,那么作为开发人员,您的任务是检查要设置的地址是否有效且网络上尚不知道。
第一:查询 DNS 是否该地址属于应用程序运行所在主机以外的主机
第二:如果 DNS 不知道该地址,则向该地址发送 Ping 请求。
请参阅:检查本地 IP 地址
如果您想“监听”冲突时,WMI 和 EventLog 是最佳选择。 EventLog 几乎是此类冲突最先出现的地方,而且很容易监控。
The question is not particular precise and old but I'll give it a go anyways because I wondered what I can do about such problems since I'm writing an app that manipulates IP addresses on the PC in order to launch applications which are dependent on specific addresses.
If anyone else has the same question I suggest trying to avoid any conflicts in the first place.
The thing is that setting an IP address is an administrative task and should only be done "free-handed" by people who know what they are doing. If you are setting IP addresses via code is is your task as a developer to check if the address to set is valid and not already known on the network.
First: Query DNS if this address belongs to a host other than the one the app runs on
Second: If DNS doesn't know about the address, send Ping requests to the address.
See: Check Local Ip Address
If you want to "listen" for conflicts, the WMI and EventLog is the way to go. The EventLog is pretty much the first place where such conflicts surface and it is easy to monitor.