Skip to content

std: implement hostname#146937

Merged
bors merged 2 commits intorust-lang:masterfrom
joboet:gethostname
Sep 30, 2025
Merged

std: implement hostname#146937
bors merged 2 commits intorust-lang:masterfrom
joboet:gethostname

Conversation

@joboet
Copy link
Copy Markdown
Member

@joboet joboet commented Sep 23, 2025

Resolves rust-lang/libs-team#330
Tracking issue: #135142

This is based on #135141, but I've reimplemented the UNIX version, which now:

  • uses sysconf(_SC_HOST_NAME_MAX) as an initial buffer length
  • returns OutOfMemory if the Vec allocation fails
  • retries the operation if it detects that the name returned by gethostname was truncated

Additionally, as part of the rebase, I had to move some WinSock abstractions (initialisation and error access) to sys::pal so that they can be accessed from sys::net::hostname.

CC @orowith2os (and thank you for your work!)

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like O-windows Operating system: Windows S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add net::hostname to retrieve the devices host name

6 participants