Skip to content

Tracking Issue for std::net::hostname #135142

Open

Description

@orowith2os

Feature gate: #![feature(gethostname)]

This is a tracking issue for retrieving the device's hostname.

rust-lang/libs-team#330 goes into far more detail; basically, "it seems to be a small but useful addition to std::net"

Public API

// std::net

pub fn hostname() -> std::io::Result<OsString>

Steps / History

  • Implementation: std: implement hostname #146937
  • Final comment period (FCP)1
  • Implementation on Windows
  • Switch to String before stabilization, as the hostname is guaranteed to be valid ASCII (OsString is therefore unnecessary).
  • Stabilization PR

Unresolved Questions

  • Will using netc be fine for all targets that support std, or do we need to do more here? I think so, since any new targets without a libc can just expose the same function signature under netc (gethostname(ptr, len))
  • On Windows, should this use GetComputerNameExW instead? See some discussion in Use gethostname on Windows djc/hostname#4
  • Is the structure of this (with functions being directly under std::net) fine, with things like gethostbyname in mind?

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-libs-api[DEPRECATED; DO NOT USE]
    on Jan 6, 2025
  2. added
    A-ioArea: `std::io` (note: `std::fs`, `std::net`, `std::path` are A-filesystem, A-net, A-path)
    on Jan 6, 2025
  3. added 2 commits that reference this issue on Sep 29, 2025
  4. added a commit that references this issue on Sep 30, 2025
  5. added a commit that references this issue on Oct 9, 2025
  6. added a commit that references this issue on Jun 27, 2026
  7. added a commit that references this issue on Jun 27, 2026
  8. added a commit that references this issue on Jun 30, 2026
  9. added a commit that references this issue on Jun 30, 2026
  10. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ioArea: `std::io` (note: `std::fs`, `std::net`, `std::path` are A-filesystem, A-net, A-path)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions