Is it necessary to attempt to connect to all addresses returned by getaddrinfo()?

后端 未结 5 2257
甜味超标
甜味超标 2021-02-14 16:33

Beej\'s Simple Client example code iterates over all IP addresses returned from getaddrinfo(), until it can connect to the first one. See the code below.

Is this always

5条回答
  •  無奈伤痛
    2021-02-14 17:02

    In addition to the other answers given above, consider the common case that for larger websites and so on, that multiple A records might be published, for redundancy purposes. If a connect() to the first address fails, you want to try the others as well.

提交回复
热议问题