开发者

Is there a built-in way to check if an IP address is already occupied?

My software changes the IP of a computer, but I 开发者_StackOverflowam coming into conflicts with other devices. Is there a built-in way to check if an IP address is already occupied/taken before setting it?

Thanks


If your network doesn't use DHCP and IP addresses really do need to be manually assigned, you could try using the System.Net.NetworkInformation.Ping class to see if a host on the network responds.


You could use the System.Net.NetworkInformation.Ping class, as Donut suggested, but not all devices will respond to Pings. However, any device with an IP address will respond to ARP requests if they are communicating with the network properly.

If you can find a way to send out an ARP request that says "Who has IP address xxx.xxx.xxx.xxx?" and you get a response, then you know someone else has that IP address. I personally don't know how to do that off the top of my head, but you could try looking at this question for information on how to access ARP information.

Also, this might be a useful resource.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜