Return True if the platform supports creating a SOCK_STREAM socket which can handle both AF_INET and AF_INET6 (IPv4 / IPv6) connections.
()
| 858 | |
| 859 | |
| 860 | def has_dualstack_ipv6(): |
| 861 | """Return True if the platform supports creating a SOCK_STREAM socket |
| 862 | which can handle both AF_INET and AF_INET6 (IPv4 / IPv6) connections. |
| 863 | """ |
| 864 | if not has_ipv6 \ |
| 865 | or not hasattr(_socket, 'IPPROTO_IPV6') \ |
| 866 | or not hasattr(_socket, 'IPV6_V6ONLY'): |
| 867 | return False |
| 868 | try: |
| 869 | with socket(AF_INET6, SOCK_STREAM) as sock: |
| 870 | sock.setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 0) |
| 871 | return True |
| 872 | except error: |
| 873 | return False |
| 874 | |
| 875 | |
| 876 | def create_server(address, *, family=AF_INET, backlog=None, reuse_port=False, |
no test coverage detected