Return True if the platform supports creating a SOCK_STREAM socket which can handle both AF_INET and AF_INET6 (IPv4 / IPv6) connections.
()
| 877 | |
| 878 | |
| 879 | def has_dualstack_ipv6(): |
| 880 | """Return True if the platform supports creating a SOCK_STREAM socket |
| 881 | which can handle both AF_INET and AF_INET6 (IPv4 / IPv6) connections. |
| 882 | """ |
| 883 | if not has_ipv6 \ |
| 884 | or not hasattr(_socket, 'IPPROTO_IPV6') \ |
| 885 | or not hasattr(_socket, 'IPV6_V6ONLY'): |
| 886 | return False |
| 887 | try: |
| 888 | with socket(AF_INET6, SOCK_STREAM) as sock: |
| 889 | sock.setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 0) |
| 890 | return True |
| 891 | except error: |
| 892 | return False |
| 893 | |
| 894 | |
| 895 | def create_server(address, *, family=AF_INET, backlog=None, reuse_port=False, |
no test coverage detected