host_name.hpp
Go to the documentation of this file.
00001 //
00002 // host_name.hpp
00003 // ~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00006 //
00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 
00011 #ifndef ASIO_IP_HOST_NAME_HPP
00012 #define ASIO_IP_HOST_NAME_HPP
00013 
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017 
00018 #include "asio/detail/push_options.hpp"
00019 
00020 #include "asio/detail/push_options.hpp"
00021 #include <string>
00022 #include "asio/detail/pop_options.hpp"
00023 
00024 #include "asio/error.hpp"
00025 #include "asio/detail/socket_ops.hpp"
00026 #include "asio/detail/throw_error.hpp"
00027 
00028 namespace asio {
00029 namespace ip {
00030 
00032 std::string host_name();
00033 
00035 std::string host_name(asio::error_code& ec);
00036 
00037 inline std::string host_name()
00038 {
00039   char name[1024];
00040   asio::error_code ec;
00041   if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
00042   {
00043     asio::detail::throw_error(ec);
00044     return std::string();
00045   }
00046   return std::string(name);
00047 }
00048 
00049 inline std::string host_name(asio::error_code& ec)
00050 {
00051   char name[1024];
00052   if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
00053     return std::string();
00054   return std::string(name);
00055 }
00056 
00057 } // namespace ip
00058 } // namespace asio
00059 
00060 #include "asio/detail/pop_options.hpp"
00061 
00062 #endif // ASIO_IP_HOST_NAME_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Castor
Author(s): Carpe Noctem
autogenerated on Fri Nov 8 2013 11:05:39