Skip to content

Add host_name() free function returning the local hostname #247

@sgerbino

Description

@sgerbino

boost::asio::ip::host_name() returns the local machine's hostname (a thin wrapper around POSIX gethostname(2) / Windows GetHostName). corosio currently has no equivalent — resolver_results::host_name() exists but returns the hostname associated with a resolved endpoint, which is a different thing.

This is a small but commonly used utility (greetings, logging, default Host: headers, cluster registration, identifying which node produced a log line).

Proposal

namespace boost::corosio {

std::string host_name();

}

Synchronous, no io_context needed. Same signature shape as asio's. Implementation is gethostname on POSIX and GetHostNameW / GetComputerNameExW on Windows.

Likely lives in a header like <boost/corosio/host_name.hpp> (or wherever the resolver-adjacent free functions land).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions