Return True if the platform supports creating a SOCK_STREAM socket which can handle both AF_INET and AF_INET6 (IPv4 / IPv6) connections.
()
| 886 | |
| 887 | |
| 888 | def has_dualstack_ipv6(): |
| 889 | """Return True if the platform supports creating a SOCK_STREAM socket |
| 890 | which can handle both AF_INET and AF_INET6 (IPv4 / IPv6) connections. |
| 891 | """ |
| 892 | if not has_ipv6 \ |
| 893 | or not hasattr(_socket, 'IPPROTO_IPV6') \ |
| 894 | or not hasattr(_socket, 'IPV6_V6ONLY'): |
| 895 | return False |
| 896 | try: |
| 897 | with socket(AF_INET6, SOCK_STREAM) as sock: |
| 898 | sock.setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 0) |
| 899 | return True |
| 900 | except error: |
| 901 | return False |
| 902 | |
| 903 | |
| 904 | def create_server(address, *, family=AF_INET, backlog=None, reuse_port=False, |
no test coverage detected
searching dependent graphs…