我们从Python开源项目中,提取了以下26个代码示例,用于说明如何使用_socket.AF_INET6。
def _parse_address(address): if isinstance(address, tuple): if ':' in address[0]: return _socket.AF_INET6, address return _socket.AF_INET, address elif isinstance(address, string_types): if ':' in address: host, port = address.rsplit(':', 1) family, host = _extract_family(host) if host == '*': host = '' return family, (host, int(port)) else: return _socket.AF_INET, ('', int(address)) elif isinstance(address, integer_types): return _socket.AF_INET, ('', int(address)) else: raise TypeError('Expected tuple or string, got %s' % type(address))
def _parse_address(address): if isinstance(address, tuple): if not address[0] or ':' in address[0]: return _socket.AF_INET6, address return _socket.AF_INET, address if ((isinstance(address, string_types) and ':' not in address) or isinstance(address, integer_types)): # noqa (pep8 E129) # Just a port return _socket.AF_INET6, ('', int(address)) if not isinstance(address, string_types): raise TypeError('Expected tuple or string, got %s' % type(address)) host, port = address.rsplit(':', 1) family, host = _extract_family(host) if host == '*': host = '' return family, (host, int(port))
def _extract_family(host): if host.startswith('[') and host.endswith(']'): host = host[1:-1] return _socket.AF_INET6, host return _socket.AF_INET, host