Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / ip / udp.hpp @ 2486

History | View | Annotate | Download (2.5 kB)

1
//
2
// ip/udp.hpp
3
// ~~~~~~~~~~
4
//
5
// Copyright (c) 2003-2015 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 BOOST_ASIO_IP_UDP_HPP
12
#define BOOST_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 <boost/asio/detail/config.hpp>
19
#include <boost/asio/basic_datagram_socket.hpp>
20
#include <boost/asio/detail/socket_types.hpp>
21
#include <boost/asio/ip/basic_endpoint.hpp>
22
#include <boost/asio/ip/basic_resolver.hpp>
23
#include <boost/asio/ip/basic_resolver_iterator.hpp>
24
#include <boost/asio/ip/basic_resolver_query.hpp>
25

    
26
#include <boost/asio/detail/push_options.hpp>
27

    
28
namespace boost {
29
namespace asio {
30
namespace ip {
31

    
32
/// Encapsulates the flags needed for UDP.
33
/**
34
 * The boost::asio::ip::udp class contains flags necessary for UDP sockets.
35
 *
36
 * @par Thread Safety
37
 * @e Distinct @e objects: Safe.@n
38
 * @e Shared @e objects: Safe.
39
 *
40
 * @par Concepts:
41
 * Protocol, InternetProtocol.
42
 */
43
class udp
44
{
45
public:
46
  /// The type of a UDP endpoint.
47
  typedef basic_endpoint<udp> endpoint;
48

    
49
  /// Construct to represent the IPv4 UDP protocol.
50
  static udp v4()
51
  {
52
    return udp(BOOST_ASIO_OS_DEF(AF_INET));
53
  }
54

    
55
  /// Construct to represent the IPv6 UDP protocol.
56
  static udp v6()
57
  {
58
    return udp(BOOST_ASIO_OS_DEF(AF_INET6));
59
  }
60

    
61
  /// Obtain an identifier for the type of the protocol.
62
  int type() const
63
  {
64
    return BOOST_ASIO_OS_DEF(SOCK_DGRAM);
65
  }
66

    
67
  /// Obtain an identifier for the protocol.
68
  int protocol() const
69
  {
70
    return BOOST_ASIO_OS_DEF(IPPROTO_UDP);
71
  }
72

    
73
  /// Obtain an identifier for the protocol family.
74
  int family() const
75
  {
76
    return family_;
77
  }
78

    
79
  /// The UDP socket type.
80
  typedef basic_datagram_socket<udp> socket;
81

    
82
  /// The UDP resolver type.
83
  typedef basic_resolver<udp> resolver;
84

    
85
  /// Compare two protocols for equality.
86
  friend bool operator==(const udp& p1, const udp& p2)
87
  {
88
    return p1.family_ == p2.family_;
89
  }
90

    
91
  /// Compare two protocols for inequality.
92
  friend bool operator!=(const udp& p1, const udp& p2)
93
  {
94
    return p1.family_ != p2.family_;
95
  }
96

    
97
private:
98
  // Construct with a specific family.
99
  explicit udp(int protocol_family)
100
    : family_(protocol_family)
101
  {
102
  }
103

    
104
  int family_;
105
};
106

    
107
} // namespace ip
108
} // namespace asio
109
} // namespace boost
110

    
111
#include <boost/asio/detail/pop_options.hpp>
112

    
113
#endif // BOOST_ASIO_IP_UDP_HPP