As usual, it is not a question of whether it can be done, but who would actually use it. We all know that Java likes to overestimate/over-engineer the feature set of its library, resulting in 98% of it never being used. We really shouldn't consider it as an example of what should be available in C/C++
. The languages have completely different philosophies, and I prefer C++'s one more.
If you look at most of the daemons running on Unix systems (where C/C++ and the Berkeley socket API originated), you will notice that they don't try to detect your interfaces and offer you a choice of which addresses to listen/bind to. This is the task of other user-space tools that serve that specific purpose. Most of the time, you would have to configure which
addresses you want to listen on (completely disregarding what interface they correspond to). The reason why there isn't an API to iterate over all the interfaces is probably because nobody would end up using it.
Instead of asking how to iterate over all interfaces, one should just take a step back and first ask what one wants to achieve by doing so. I really can't think of any use case where it would make sense.