MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / getfqdn

Function getfqdn

tools/python-3.11.9-amd64/Lib/socket.py:780–804  ·  view source on GitHub ↗

Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available and `name` was given, it is returned unchanged. If `n

(name='')

Source from the content-addressed store, hash-verified

778
779
780def getfqdn(name=''):
781 """Get fully qualified domain name from name.
782
783 An empty argument is interpreted as meaning the local host.
784
785 First the hostname returned by gethostbyaddr() is checked, then
786 possibly existing aliases. In case no FQDN is available and `name`
787 was given, it is returned unchanged. If `name` was empty, '0.0.0.0' or '::',
788 hostname from gethostname() is returned.
789 """
790 name = name.strip()
791 if not name or name in ('0.0.0.0', '::'):
792 name = gethostname()
793 try:
794 hostname, aliases, ipaddrs = gethostbyaddr(name)
795 except error:
796 pass
797 else:
798 aliases.insert(0, hostname)
799 for name in aliases:
800 if '.' in name:
801 break
802 else:
803 name = hostname
804 return name
805
806
807_GLOBAL_DEFAULT_TIMEOUT = object()

Callers

nothing calls this directly

Calls 2

stripMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected