Get a list of devices on a local network in C

I would like to get a list of available devices (their IP address or hostname should be good) connected to my local network. I have some examples in C #, but I could not find any sample using C / C ++. I am familiar with the BSD API, just for clarification.

I have an idea of ​​a β€œstub”: perhaps I should determine the range of IP addresses to which devices on my local network can belong, and then determine if they are e. d. respond to ping or something like that. How can i achieve this?

I want my application to run on Linux and iOS. Therefore, I would prefer BSD sockets or the maximum, Foundation / GNUstep (although they are written in Objective-C).

+4
source share
1 answer

You can also, for example, send an ICMP sounder request packet to 224.0.0.1. This is a special multicast address for all nodes to which each node must respond (unless this prohibits the use of a firewall rule or network policy).

+12
source

Source: https://habr.com/ru/post/1393631/


All Articles