Ticket #3131: dccp.hpp

File dccp.hpp, 2.6 KB (added by oakad@…, 13 years ago)

DCCP protocol header

Line 
1//
2// dccp.hpp
3// ~~~~~~~~
4//
5// Copyright (c) 2009 Alexander Dubov (oakad at yahoo 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_DCCP_HPP
12#define BOOST_ASIO_IP_DCCP_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/push_options.hpp>
19
20#include "basic_dccp_socket.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#include <boost/asio/detail/socket_types.hpp>
26
27namespace boost {
28namespace asio {
29namespace ip {
30/// Encapsulates the flags needed for DCCP.
31/**
32 * The boost::asio::ip::dccp 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 */
41class dccp
42{
43public:
44 /// The type of a DCCP endpoint.
45 typedef basic_endpoint<dccp> endpoint;
46
47 /// The type of a resolver query.
48 typedef basic_resolver_query<dccp> resolver_query;
49
50 /// The type of a resolver iterator.
51 typedef basic_resolver_iterator<dccp> resolver_iterator;
52
53 /// Construct to represent the IPv4 DCCP protocol.
54 static dccp v4()
55 {
56 return dccp(PF_INET);
57 }
58
59 /// Construct to represent the IPv6 DCCP protocol.
60 static dccp v6()
61 {
62 return dccp(PF_INET6);
63 }
64
65 /// Obtain an identifier for the type of the protocol.
66 int type() const
67 {
68 return SOCK_DCCP;
69 }
70
71 /// Obtain an identifier for the protocol.
72 int protocol() const
73 {
74 return IPPROTO_DCCP;
75 }
76
77 /// Obtain an identifier for the protocol family.
78 int family() const
79 {
80 return family_;
81 }
82
83 /// The DCCP socket type.
84 typedef basic_dccp_socket<dccp> socket;
85
86 /// The DCCP acceptor type.
87 typedef basic_socket_acceptor<dccp> acceptor;
88
89 /// The DCCP resolver type.
90 typedef basic_resolver<dccp> resolver;
91
92 /// Compare two protocols for equality.
93 friend bool operator==(const dccp& p1, const dccp& p2)
94 {
95 return p1.family_ == p2.family_;
96 }
97
98 /// Compare two protocols for inequality.
99 friend bool operator!=(const dccp& p1, const dccp& p2)
100 {
101 return p1.family_ != p2.family_;
102 }
103
104private:
105 // Construct with a specific family.
106 explicit dccp(int family)
107 : family_(family)
108 {
109 }
110
111 int family_;
112};
113
114} // namespace ip
115} // namespace asio
116} // namespace boost
117
118#include <boost/asio/detail/pop_options.hpp>
119
120#endif // BOOST_ASIO_IP_DCCP_HPP