~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to include/libtorrent/asio/ip/host_name.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// host_name.hpp
3
 
// ~~~~~~~~~~~~~
4
 
//
5
 
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6
 
//
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)
9
 
//
10
 
 
11
 
#ifndef ASIO_IP_HOST_NAME_HPP
12
 
#define ASIO_IP_HOST_NAME_HPP
13
 
 
14
 
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15
 
# pragma once
16
 
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
 
 
18
 
#include "asio/detail/push_options.hpp"
19
 
 
20
 
#include "asio/detail/push_options.hpp"
21
 
#include <string>
22
 
#include "asio/detail/pop_options.hpp"
23
 
 
24
 
#include "asio/error.hpp"
25
 
#include "asio/detail/socket_ops.hpp"
26
 
#include "asio/detail/throw_error.hpp"
27
 
 
28
 
namespace asio {
29
 
namespace ip {
30
 
 
31
 
/// Get the current host name.
32
 
std::string host_name();
33
 
 
34
 
/// Get the current host name.
35
 
std::string host_name(asio::error_code& ec);
36
 
 
37
 
inline std::string host_name()
38
 
{
39
 
  char name[1024];
40
 
  asio::error_code ec;
41
 
  if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
42
 
  {
43
 
    asio::detail::throw_error(ec);
44
 
    return std::string();
45
 
  }
46
 
  return std::string(name);
47
 
}
48
 
 
49
 
inline std::string host_name(asio::error_code& ec)
50
 
{
51
 
  char name[1024];
52
 
  if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
53
 
    return std::string();
54
 
  return std::string(name);
55
 
}
56
 
 
57
 
} // namespace ip
58
 
} // namespace asio
59
 
 
60
 
#include "asio/detail/pop_options.hpp"
61
 
 
62
 
#endif // ASIO_IP_HOST_NAME_HPP