Commit fe27a508 authored by Guido van Rossum's avatar Guido van Rossum

Added warning that gethostname() doesn't always return fqdn, and show

how to find it using gethostbyaddr().
parent 5709dcfa
...@@ -96,6 +96,9 @@ Return a string containing the hostname of the machine where ...@@ -96,6 +96,9 @@ Return a string containing the hostname of the machine where
the Python interpreter is currently executing. If you want to know the the Python interpreter is currently executing. If you want to know the
current machine's IP address, use current machine's IP address, use
\code{socket.gethostbyname(socket.gethostname())}. \code{socket.gethostbyname(socket.gethostname())}.
Note: \code{gethostname()} doesn't always return the fully qualified
domain name; use \code{socket.gethostbyaddr(socket.gethostname())}
(see below).
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{gethostbyaddr}{ip_address} \begin{funcdesc}{gethostbyaddr}{ip_address}
...@@ -105,6 +108,8 @@ Return a triple \code{(hostname, aliaslist, ipaddrlist)} where ...@@ -105,6 +108,8 @@ Return a triple \code{(hostname, aliaslist, ipaddrlist)} where
alternative host names for the same address, and \code{ipaddrlist} is alternative host names for the same address, and \code{ipaddrlist} is
a list of IP addresses for the same interface on the same a list of IP addresses for the same interface on the same
host (most likely containing only a single address). host (most likely containing only a single address).
To find the fully qualified domain name, check \var{hostname} and the
items of \var{aliaslist} for an entry containing at least one period.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getprotobyname}{protocolname} \begin{funcdesc}{getprotobyname}{protocolname}
......
...@@ -96,6 +96,9 @@ Return a string containing the hostname of the machine where ...@@ -96,6 +96,9 @@ Return a string containing the hostname of the machine where
the Python interpreter is currently executing. If you want to know the the Python interpreter is currently executing. If you want to know the
current machine's IP address, use current machine's IP address, use
\code{socket.gethostbyname(socket.gethostname())}. \code{socket.gethostbyname(socket.gethostname())}.
Note: \code{gethostname()} doesn't always return the fully qualified
domain name; use \code{socket.gethostbyaddr(socket.gethostname())}
(see below).
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{gethostbyaddr}{ip_address} \begin{funcdesc}{gethostbyaddr}{ip_address}
...@@ -105,6 +108,8 @@ Return a triple \code{(hostname, aliaslist, ipaddrlist)} where ...@@ -105,6 +108,8 @@ Return a triple \code{(hostname, aliaslist, ipaddrlist)} where
alternative host names for the same address, and \code{ipaddrlist} is alternative host names for the same address, and \code{ipaddrlist} is
a list of IP addresses for the same interface on the same a list of IP addresses for the same interface on the same
host (most likely containing only a single address). host (most likely containing only a single address).
To find the fully qualified domain name, check \var{hostname} and the
items of \var{aliaslist} for an entry containing at least one period.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getprotobyname}{protocolname} \begin{funcdesc}{getprotobyname}{protocolname}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment