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

« back to all changes in this revision

Viewing changes to include/libtorrent/asio/ip/udp.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
 
// udp.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_UDP_HPP
12
 
#define ASIO_IP_UDP_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/basic_datagram_socket.hpp"
21
 
#include "asio/ip/basic_endpoint.hpp"
22
 
#include "asio/ip/basic_resolver.hpp"
23
 
#include "asio/ip/basic_resolver_iterator.hpp"
24
 
#include "asio/ip/basic_resolver_query.hpp"
25
 
#include "asio/detail/socket_types.hpp"
26
 
 
27
 
namespace asio {
28
 
namespace ip {
29
 
 
30
 
/// Encapsulates the flags needed for UDP.
31
 
/**
32
 
 * The asio::ip::udp class contains flags necessary for UDP sockets.
33
 
 *
34
 
 * @par Thread Safety
35
 
 * @e Distinct @e objects: Safe.@n
36
 
 * @e Shared @e objects: Safe.
37
 
 *
38
 
 * @par Concepts:
39
 
 * Protocol, InternetProtocol.
40
 
 */
41
 
class udp
42
 
{
43
 
public:
44
 
  /// The type of a UDP endpoint.
45
 
  typedef basic_endpoint<udp> endpoint;
46
 
 
47
 
  /// The type of a resolver query.
48
 
  typedef basic_resolver_query<udp> resolver_query;
49
 
 
50
 
  /// The type of a resolver iterator.
51
 
  typedef basic_resolver_iterator<udp> resolver_iterator;
52
 
 
53
 
  /// Construct to represent the IPv4 UDP protocol.
54
 
  static udp v4()
55
 
  {
56
 
    return udp(PF_INET);
57
 
  }
58
 
 
59
 
  /// Construct to represent the IPv6 UDP protocol.
60
 
  static udp v6()
61
 
  {
62
 
    return udp(PF_INET6);
63
 
  }
64
 
 
65
 
  /// Obtain an identifier for the type of the protocol.
66
 
  int type() const
67
 
  {
68
 
    return SOCK_DGRAM;
69
 
  }
70
 
 
71
 
  /// Obtain an identifier for the protocol.
72
 
  int protocol() const
73
 
  {
74
 
    return IPPROTO_UDP;
75
 
  }
76
 
 
77
 
  /// Obtain an identifier for the protocol family.
78
 
  int family() const
79
 
  {
80
 
    return family_;
81
 
  }
82
 
 
83
 
  /// The UDP socket type.
84
 
  typedef basic_datagram_socket<udp> socket;
85
 
 
86
 
  /// The UDP resolver type.
87
 
  typedef basic_resolver<udp> resolver;
88
 
 
89
 
  /// Compare two protocols for equality.
90
 
  friend bool operator==(const udp& p1, const udp& p2)
91
 
  {
92
 
    return p1.family_ == p2.family_;
93
 
  }
94
 
 
95
 
  /// Compare two protocols for inequality.
96
 
  friend bool operator!=(const udp& p1, const udp& p2)
97
 
  {
98
 
    return p1.family_ != p2.family_;
99
 
  }
100
 
 
101
 
private:
102
 
  // Construct with a specific family.
103
 
  explicit udp(int family)
104
 
    : family_(family)
105
 
  {
106
 
  }
107
 
 
108
 
  int family_;
109
 
};
110
 
 
111
 
} // namespace ip
112
 
} // namespace asio
113
 
 
114
 
#include "asio/detail/pop_options.hpp"
115
 
 
116
 
#endif // ASIO_IP_UDP_HPP