5
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11
#ifndef ASIO_IP_HOST_NAME_HPP
12
#define ASIO_IP_HOST_NAME_HPP
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
#include "asio/detail/push_options.hpp"
20
#include "asio/detail/push_options.hpp"
22
#include "asio/detail/pop_options.hpp"
24
#include "asio/error.hpp"
25
#include "asio/detail/socket_ops.hpp"
26
#include "asio/detail/throw_error.hpp"
31
/// Get the current host name.
32
std::string host_name();
34
/// Get the current host name.
35
std::string host_name(asio::error_code& ec);
37
inline std::string host_name()
41
if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
43
asio::detail::throw_error(ec);
46
return std::string(name);
49
inline std::string host_name(asio::error_code& ec)
52
if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
54
return std::string(name);
60
#include "asio/detail/pop_options.hpp"
62
#endif // ASIO_IP_HOST_NAME_HPP