Socket listener for IPv6 and IPv4

前端 未结 2 1533
时光说笑
时光说笑 2020-12-21 01:04

I ported an application to support IPv6, using popular tutorials. I decided to use only one socket listener for both protocols. Now I realized I have to set IPV6_V6ONL

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 01:21

    It is fine either way.

    If you bind v4 and v6 explicitly, you need to set IPV6_V6ONLY, otherwise, you need to clear it. The default setting varies between platforms.

    Some platforms do not support accepting v4 connections on v6 sockets, so for maximum compatibility I'd go with the "two sockets" approach.

提交回复
热议问题