From the course: Network Programming in C: Develop Reliable Client/Server Applications

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Discover local interfaces

Discover local interfaces

- [Instructor] Modern computers feature multiple network interfaces. In Linux, the command to output this information is IP address, ADDR, show. This list outputs tons of detail. For Mac OS in the terminal app, use the command IF config to see similar information. Some computers may use IP config, again, to output the same or similar information. You can also glean this information in your C code, thanks to the get IF ADDRS function. This function is defined in the IFADDRS H header file. It requires a single argument, the address of a pointer to an IF ADDRS structure. The function returns zero upon success, negative one, otherwise with an error, no value set, indicating the error. This is the IF ADDRS structure's definition from the man page. It's a length list, as you can see, by the IFA next member. The IFA name member is the interface's name, a string, and the IFA ADDR member is another structure that contains the IP…

Contents