1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
//
// ip/multicast.hpp
// ~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_IP_MULTICAST_HPP
#define ASIO_IP_MULTICAST_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include <cstddef>
#include "asio/ip/detail/socket_option.hpp"
#include "asio/detail/push_options.hpp"
namespace asio {
namespace ip {
namespace multicast {
/// Socket option to join a multicast group on a specified interface.
/**
* Implements the IPPROTO_IP/IP_ADD_MEMBERSHIP socket option.
*
* @par Examples
* Setting the option to join a multicast group:
* @code
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::address multicast_address =
* asio::ip::address::from_string("225.0.0.1");
* asio::ip::multicast::join_group option(multicast_address);
* socket.set_option(option);
* @endcode
*
* @par Concepts:
* SettableSocketOption.
*/
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined join_group;
#else
typedef asio::ip::detail::socket_option::multicast_request<
ASIO_OS_DEF(IPPROTO_IP),
ASIO_OS_DEF(IP_ADD_MEMBERSHIP),
ASIO_OS_DEF(IPPROTO_IPV6),
ASIO_OS_DEF(IPV6_JOIN_GROUP)> join_group;
#endif
/// Socket option to leave a multicast group on a specified interface.
/**
* Implements the IPPROTO_IP/IP_DROP_MEMBERSHIP socket option.
*
* @par Examples
* Setting the option to leave a multicast group:
* @code
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::address multicast_address =
* asio::ip::address::from_string("225.0.0.1");
* asio::ip::multicast::leave_group option(multicast_address);
* socket.set_option(option);
* @endcode
*
* @par Concepts:
* SettableSocketOption.
*/
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined leave_group;
#else
typedef asio::ip::detail::socket_option::multicast_request<
ASIO_OS_DEF(IPPROTO_IP),
ASIO_OS_DEF(IP_DROP_MEMBERSHIP),
ASIO_OS_DEF(IPPROTO_IPV6),
ASIO_OS_DEF(IPV6_LEAVE_GROUP)> leave_group;
#endif
/// Socket option for local interface to use for outgoing multicast packets.
/**
* Implements the IPPROTO_IP/IP_MULTICAST_IF socket option.
*
* @par Examples
* Setting the option:
* @code
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::address_v4 local_interface =
* asio::ip::address_v4::from_string("1.2.3.4");
* asio::ip::multicast::outbound_interface option(local_interface);
* socket.set_option(option);
* @endcode
*
* @par Concepts:
* SettableSocketOption.
*/
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined outbound_interface;
#else
typedef asio::ip::detail::socket_option::network_interface<
ASIO_OS_DEF(IPPROTO_IP),
ASIO_OS_DEF(IP_MULTICAST_IF),
ASIO_OS_DEF(IPPROTO_IPV6),
ASIO_OS_DEF(IPV6_MULTICAST_IF)> outbound_interface;
#endif
/// Socket option for time-to-live associated with outgoing multicast packets.
/**
* Implements the IPPROTO_IP/IP_MULTICAST_TTL socket option.
*
* @par Examples
* Setting the option:
* @code
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::multicast::hops option(4);
* socket.set_option(option);
* @endcode
*
* @par
* Getting the current option value:
* @code
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::multicast::hops option;
* socket.get_option(option);
* int ttl = option.value();
* @endcode
*
* @par Concepts:
* GettableSocketOption, SettableSocketOption.
*/
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined hops;
#else
typedef asio::ip::detail::socket_option::multicast_hops<
ASIO_OS_DEF(IPPROTO_IP),
ASIO_OS_DEF(IP_MULTICAST_TTL),
ASIO_OS_DEF(IPPROTO_IPV6),
ASIO_OS_DEF(IPV6_MULTICAST_HOPS)> hops;
#endif
/// Socket option determining whether outgoing multicast packets will be
/// received on the same socket if it is a member of the multicast group.
/**
* Implements the IPPROTO_IP/IP_MULTICAST_LOOP socket option.
*
* @par Examples
* Setting the option:
* @code
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::multicast::enable_loopback option(true);
* socket.set_option(option);
* @endcode
*
* @par
* Getting the current option value:
* @code
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::multicast::enable_loopback option;
* socket.get_option(option);
* bool is_set = option.value();
* @endcode
*
* @par Concepts:
* GettableSocketOption, SettableSocketOption.
*/
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined enable_loopback;
#else
typedef asio::ip::detail::socket_option::multicast_enable_loopback<
ASIO_OS_DEF(IPPROTO_IP),
ASIO_OS_DEF(IP_MULTICAST_LOOP),
ASIO_OS_DEF(IPPROTO_IPV6),
ASIO_OS_DEF(IPV6_MULTICAST_LOOP)> enable_loopback;
#endif
} // namespace multicast
} // namespace ip
} // namespace asio
#include "asio/detail/pop_options.hpp"
#endif // ASIO_IP_MULTICAST_HPP
|