pub fn gethostname() -> OsString
Expand description
Get the standard host name for the current machine.
On Unix call rustix::system::uname
to obtain the node name, see
rustix::system::Uname::nodename
.
On Windows return the DNS host name of the local computer, as returned by
GetComputerNameExW with ComputerNamePhysicalDnsHostname
as NameType
.
We call this function twice to obtain the appropriate buffer size; there is
a race condition window between these two calls where a change to the node
name would result in a wrong buffer size which could cause this function to
panic.
Note that this host name does not have a well-defined meaning in terms of network name resolution. Specifically, it’s not guaranteed that the returned name can be resolved in any particular way, e.g. DNS.