What was the motivation for adding the IPV6_V6ONLY flag?

前端 未结 7 1379
攒了一身酷
攒了一身酷 2021-02-07 00:39

In IPv6 networking, the IPV6_V6ONLY flag is used to ensure that a socket will only use IPv6, and in particular that IPv4-to-IPv6 mapping won\'t be used for that socket. On many

7条回答
  •  礼貌的吻别
    2021-02-07 01:06

    For Linux, when writing a service that listens on both IPv4 and IPv6 sockets on the same service port, e.g. port 2001, you MUST call setsockopt(s, SOL_IPV6, IPV6_V6ONLY, &one, sizeof(one)); on the IPv6 socket. If you do not, the bind() operation for the IPv4 socket fails with "Address already in use".

提交回复
热议问题