11 #ifndef ASIO_DETAIL_SOCKET_OPTION_HPP 12 #define ASIO_DETAIL_SOCKET_OPTION_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 21 #include "asio/detail/socket_types.hpp" 22 #include "asio/detail/throw_exception.hpp" 24 #include "asio/detail/push_options.hpp" 28 namespace socket_option {
31 template <
int Level,
int Name>
48 boolean& operator=(
bool v)
67 bool operator!()
const 73 template <
typename Protocol>
74 int level(
const Protocol&)
const 80 template <
typename Protocol>
81 int name(
const Protocol&)
const 87 template <
typename Protocol>
88 int* data(
const Protocol&)
94 template <
typename Protocol>
95 const int* data(
const Protocol&)
const 101 template <
typename Protocol>
102 std::size_t size(
const Protocol&)
const 104 return sizeof(value_);
108 template <
typename Protocol>
109 void resize(
const Protocol&, std::size_t
s)
117 value_ = *reinterpret_cast<char*>(&value_) ? 1 : 0;
123 std::length_error ex(
"boolean socket option resize");
124 asio::detail::throw_exception(ex);
134 template <
int Level,
int Name>
164 template <
typename Protocol>
165 int level(
const Protocol&)
const 171 template <
typename Protocol>
172 int name(
const Protocol&)
const 178 template <
typename Protocol>
179 int* data(
const Protocol&)
185 template <
typename Protocol>
186 const int* data(
const Protocol&)
const 192 template <
typename Protocol>
193 std::size_t size(
const Protocol&)
const 195 return sizeof(value_);
199 template <
typename Protocol>
200 void resize(
const Protocol&, std::size_t
s)
202 if (s !=
sizeof(value_))
204 std::length_error ex(
"integer socket option resize");
205 asio::detail::throw_exception(ex);
214 template <
int Level,
int Name>
229 timeout ASIO_PREVENT_MACRO_SUBSTITUTION(t);
233 void enabled(
bool value)
235 value_.l_onoff = value ? 1 : 0;
241 return value_.l_onoff != 0;
245 void timeout ASIO_PREVENT_MACRO_SUBSTITUTION(
int value)
248 value_.l_linger =
static_cast<u_short
>(value);
250 value_.l_linger = value;
255 int timeout ASIO_PREVENT_MACRO_SUBSTITUTION()
const 257 return static_cast<int>(value_.l_linger);
261 template <
typename Protocol>
262 int level(
const Protocol&)
const 268 template <
typename Protocol>
269 int name(
const Protocol&)
const 275 template <
typename Protocol>
276 detail::linger_type* data(
const Protocol&)
282 template <
typename Protocol>
283 const detail::linger_type* data(
const Protocol&)
const 289 template <
typename Protocol>
290 std::size_t size(
const Protocol&)
const 292 return sizeof(value_);
296 template <
typename Protocol>
297 void resize(
const Protocol&, std::size_t
s)
299 if (s !=
sizeof(value_))
301 std::length_error ex(
"linger socket option resize");
302 asio::detail::throw_exception(ex);
307 detail::linger_type value_;
314 #include "asio/detail/pop_options.hpp" 316 #endif // ASIO_DETAIL_SOCKET_OPTION_HPP Definition: socket_option.hpp:215
Definition: blocking.hpp:208
Definition: socket_option.hpp:135
Definition: socket_option.hpp:32
Definition: any_io_executor.hpp:28