I noticed that AddressList contains nothing, AddressList the loopback address. I'm not sure about other indices.
If I have created a server on one machine and it wants to populate its IP to client (may be the machine only), then which IP (among host.AddressList) shall I populate? Which index to use? How do I know whether I'm connected to a LAN or the internet, or not connected at all? Please clarify.
How do I know whether I'm connected to a LAN or the internet, or not connected at all?
Depends on the purpose of application since design of internet makes such question impossible to answer reliably.
For LAN, one can check the IP. If it's 10.0.x.x or 192.168.x.x, then machine is likely on LAN. Query like this cannot determine the actual connection topology, just about all machines are on some sort of LAN (as opposed to being directly on internet backbone), so it depends on why query like that is used. For a rough estimate of WAN connectivity, try to download something from a DNS-resolved location (it's what Windows does). While it doesn't guarantee full internet access, one can say that some WAN addresses are resolvable and routable through current interface. Ideally, you'd query some resource you own, such as your own server since that's all that matters to an application, even if the rest is non-routable or non-resolvable.
External-facing IP can be determined through a third-party service which replies with IP from which it received a request.
then which IP (among host.AddressList) shall I populate? Which index to use?
Again, depends on purpose. Trying to determine server's external IP this way is of limited use.