PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/external/mac/boost.framework/Versions/A/Headers/asio/socket_base.hpp

https://gitlab.com/alvinahmadov2/icq-desktop
C++ Header | 522 lines | 144 code | 31 blank | 347 comment | 1 complexity | ee7ddf5b5cb6b7576ab0bb5482da4505 MD5 | raw file
  1. //
  2. // socket_base.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. #ifndef BOOST_ASIO_SOCKET_BASE_HPP
  11. #define BOOST_ASIO_SOCKET_BASE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/detail/io_control.hpp>
  17. #include <boost/asio/detail/socket_option.hpp>
  18. #include <boost/asio/detail/socket_types.hpp>
  19. #include <boost/asio/detail/push_options.hpp>
  20. namespace boost {
  21. namespace asio {
  22. /// The socket_base class is used as a base for the basic_stream_socket and
  23. /// basic_datagram_socket class templates so that we have a common place to
  24. /// define the shutdown_type and enum.
  25. class socket_base
  26. {
  27. public:
  28. /// Different ways a socket may be shutdown.
  29. enum shutdown_type
  30. {
  31. #if defined(GENERATING_DOCUMENTATION)
  32. /// Shutdown the receive side of the socket.
  33. shutdown_receive = implementation_defined,
  34. /// Shutdown the send side of the socket.
  35. shutdown_send = implementation_defined,
  36. /// Shutdown both send and receive on the socket.
  37. shutdown_both = implementation_defined
  38. #else
  39. shutdown_receive = BOOST_ASIO_OS_DEF(SHUT_RD),
  40. shutdown_send = BOOST_ASIO_OS_DEF(SHUT_WR),
  41. shutdown_both = BOOST_ASIO_OS_DEF(SHUT_RDWR)
  42. #endif
  43. };
  44. /// Bitmask type for flags that can be passed to send and receive operations.
  45. typedef int message_flags;
  46. #if defined(GENERATING_DOCUMENTATION)
  47. /// Peek at incoming data without removing it from the input queue.
  48. static const int message_peek = implementation_defined;
  49. /// Process out-of-band data.
  50. static const int message_out_of_band = implementation_defined;
  51. /// Specify that the data should not be subject to routing.
  52. static const int message_do_not_route = implementation_defined;
  53. /// Specifies that the data marks the end of a record.
  54. static const int message_end_of_record = implementation_defined;
  55. #else
  56. BOOST_ASIO_STATIC_CONSTANT(int,
  57. message_peek = BOOST_ASIO_OS_DEF(MSG_PEEK));
  58. BOOST_ASIO_STATIC_CONSTANT(int,
  59. message_out_of_band = BOOST_ASIO_OS_DEF(MSG_OOB));
  60. BOOST_ASIO_STATIC_CONSTANT(int,
  61. message_do_not_route = BOOST_ASIO_OS_DEF(MSG_DONTROUTE));
  62. BOOST_ASIO_STATIC_CONSTANT(int,
  63. message_end_of_record = BOOST_ASIO_OS_DEF(MSG_EOR));
  64. #endif
  65. /// Socket option to permit sending of broadcast messages.
  66. /**
  67. * Implements the SOL_SOCKET/SO_BROADCAST socket option.
  68. *
  69. * @par Examples
  70. * Setting the option:
  71. * @code
  72. * boost::asio::ip::udp::socket socket(io_service);
  73. * ...
  74. * boost::asio::socket_base::broadcast option(true);
  75. * socket.set_option(option);
  76. * @endcode
  77. *
  78. * @par
  79. * Getting the current option value:
  80. * @code
  81. * boost::asio::ip::udp::socket socket(io_service);
  82. * ...
  83. * boost::asio::socket_base::broadcast option;
  84. * socket.get_option(option);
  85. * bool is_set = option.value();
  86. * @endcode
  87. *
  88. * @par Concepts:
  89. * Socket_Option, Boolean_Socket_Option.
  90. */
  91. #if defined(GENERATING_DOCUMENTATION)
  92. typedef implementation_defined broadcast;
  93. #else
  94. typedef boost::asio::detail::socket_option::boolean<
  95. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_BROADCAST)>
  96. broadcast;
  97. #endif
  98. /// Socket option to enable socket-level debugging.
  99. /**
  100. * Implements the SOL_SOCKET/SO_DEBUG socket option.
  101. *
  102. * @par Examples
  103. * Setting the option:
  104. * @code
  105. * boost::asio::ip::tcp::socket socket(io_service);
  106. * ...
  107. * boost::asio::socket_base::debug option(true);
  108. * socket.set_option(option);
  109. * @endcode
  110. *
  111. * @par
  112. * Getting the current option value:
  113. * @code
  114. * boost::asio::ip::tcp::socket socket(io_service);
  115. * ...
  116. * boost::asio::socket_base::debug option;
  117. * socket.get_option(option);
  118. * bool is_set = option.value();
  119. * @endcode
  120. *
  121. * @par Concepts:
  122. * Socket_Option, Boolean_Socket_Option.
  123. */
  124. #if defined(GENERATING_DOCUMENTATION)
  125. typedef implementation_defined debug;
  126. #else
  127. typedef boost::asio::detail::socket_option::boolean<
  128. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_DEBUG)> debug;
  129. #endif
  130. /// Socket option to prevent routing, use local interfaces only.
  131. /**
  132. * Implements the SOL_SOCKET/SO_DONTROUTE socket option.
  133. *
  134. * @par Examples
  135. * Setting the option:
  136. * @code
  137. * boost::asio::ip::udp::socket socket(io_service);
  138. * ...
  139. * boost::asio::socket_base::do_not_route option(true);
  140. * socket.set_option(option);
  141. * @endcode
  142. *
  143. * @par
  144. * Getting the current option value:
  145. * @code
  146. * boost::asio::ip::udp::socket socket(io_service);
  147. * ...
  148. * boost::asio::socket_base::do_not_route option;
  149. * socket.get_option(option);
  150. * bool is_set = option.value();
  151. * @endcode
  152. *
  153. * @par Concepts:
  154. * Socket_Option, Boolean_Socket_Option.
  155. */
  156. #if defined(GENERATING_DOCUMENTATION)
  157. typedef implementation_defined do_not_route;
  158. #else
  159. typedef boost::asio::detail::socket_option::boolean<
  160. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_DONTROUTE)>
  161. do_not_route;
  162. #endif
  163. /// Socket option to send keep-alives.
  164. /**
  165. * Implements the SOL_SOCKET/SO_KEEPALIVE socket option.
  166. *
  167. * @par Examples
  168. * Setting the option:
  169. * @code
  170. * boost::asio::ip::tcp::socket socket(io_service);
  171. * ...
  172. * boost::asio::socket_base::keep_alive option(true);
  173. * socket.set_option(option);
  174. * @endcode
  175. *
  176. * @par
  177. * Getting the current option value:
  178. * @code
  179. * boost::asio::ip::tcp::socket socket(io_service);
  180. * ...
  181. * boost::asio::socket_base::keep_alive option;
  182. * socket.get_option(option);
  183. * bool is_set = option.value();
  184. * @endcode
  185. *
  186. * @par Concepts:
  187. * Socket_Option, Boolean_Socket_Option.
  188. */
  189. #if defined(GENERATING_DOCUMENTATION)
  190. typedef implementation_defined keep_alive;
  191. #else
  192. typedef boost::asio::detail::socket_option::boolean<
  193. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_KEEPALIVE)> keep_alive;
  194. #endif
  195. /// Socket option for the send buffer size of a socket.
  196. /**
  197. * Implements the SOL_SOCKET/SO_SNDBUF socket option.
  198. *
  199. * @par Examples
  200. * Setting the option:
  201. * @code
  202. * boost::asio::ip::tcp::socket socket(io_service);
  203. * ...
  204. * boost::asio::socket_base::send_buffer_size option(8192);
  205. * socket.set_option(option);
  206. * @endcode
  207. *
  208. * @par
  209. * Getting the current option value:
  210. * @code
  211. * boost::asio::ip::tcp::socket socket(io_service);
  212. * ...
  213. * boost::asio::socket_base::send_buffer_size option;
  214. * socket.get_option(option);
  215. * int size = option.value();
  216. * @endcode
  217. *
  218. * @par Concepts:
  219. * Socket_Option, Integer_Socket_Option.
  220. */
  221. #if defined(GENERATING_DOCUMENTATION)
  222. typedef implementation_defined send_buffer_size;
  223. #else
  224. typedef boost::asio::detail::socket_option::integer<
  225. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_SNDBUF)>
  226. send_buffer_size;
  227. #endif
  228. /// Socket option for the send low watermark.
  229. /**
  230. * Implements the SOL_SOCKET/SO_SNDLOWAT socket option.
  231. *
  232. * @par Examples
  233. * Setting the option:
  234. * @code
  235. * boost::asio::ip::tcp::socket socket(io_service);
  236. * ...
  237. * boost::asio::socket_base::send_low_watermark option(1024);
  238. * socket.set_option(option);
  239. * @endcode
  240. *
  241. * @par
  242. * Getting the current option value:
  243. * @code
  244. * boost::asio::ip::tcp::socket socket(io_service);
  245. * ...
  246. * boost::asio::socket_base::send_low_watermark option;
  247. * socket.get_option(option);
  248. * int size = option.value();
  249. * @endcode
  250. *
  251. * @par Concepts:
  252. * Socket_Option, Integer_Socket_Option.
  253. */
  254. #if defined(GENERATING_DOCUMENTATION)
  255. typedef implementation_defined send_low_watermark;
  256. #else
  257. typedef boost::asio::detail::socket_option::integer<
  258. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_SNDLOWAT)>
  259. send_low_watermark;
  260. #endif
  261. /// Socket option for the receive buffer size of a socket.
  262. /**
  263. * Implements the SOL_SOCKET/SO_RCVBUF socket option.
  264. *
  265. * @par Examples
  266. * Setting the option:
  267. * @code
  268. * boost::asio::ip::tcp::socket socket(io_service);
  269. * ...
  270. * boost::asio::socket_base::receive_buffer_size option(8192);
  271. * socket.set_option(option);
  272. * @endcode
  273. *
  274. * @par
  275. * Getting the current option value:
  276. * @code
  277. * boost::asio::ip::tcp::socket socket(io_service);
  278. * ...
  279. * boost::asio::socket_base::receive_buffer_size option;
  280. * socket.get_option(option);
  281. * int size = option.value();
  282. * @endcode
  283. *
  284. * @par Concepts:
  285. * Socket_Option, Integer_Socket_Option.
  286. */
  287. #if defined(GENERATING_DOCUMENTATION)
  288. typedef implementation_defined receive_buffer_size;
  289. #else
  290. typedef boost::asio::detail::socket_option::integer<
  291. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_RCVBUF)>
  292. receive_buffer_size;
  293. #endif
  294. /// Socket option for the receive low watermark.
  295. /**
  296. * Implements the SOL_SOCKET/SO_RCVLOWAT socket option.
  297. *
  298. * @par Examples
  299. * Setting the option:
  300. * @code
  301. * boost::asio::ip::tcp::socket socket(io_service);
  302. * ...
  303. * boost::asio::socket_base::receive_low_watermark option(1024);
  304. * socket.set_option(option);
  305. * @endcode
  306. *
  307. * @par
  308. * Getting the current option value:
  309. * @code
  310. * boost::asio::ip::tcp::socket socket(io_service);
  311. * ...
  312. * boost::asio::socket_base::receive_low_watermark option;
  313. * socket.get_option(option);
  314. * int size = option.value();
  315. * @endcode
  316. *
  317. * @par Concepts:
  318. * Socket_Option, Integer_Socket_Option.
  319. */
  320. #if defined(GENERATING_DOCUMENTATION)
  321. typedef implementation_defined receive_low_watermark;
  322. #else
  323. typedef boost::asio::detail::socket_option::integer<
  324. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_RCVLOWAT)>
  325. receive_low_watermark;
  326. #endif
  327. /// Socket option to allow the socket to be bound to an address that is
  328. /// already in use.
  329. /**
  330. * Implements the SOL_SOCKET/SO_REUSEADDR socket option.
  331. *
  332. * @par Examples
  333. * Setting the option:
  334. * @code
  335. * boost::asio::ip::tcp::acceptor acceptor(io_service);
  336. * ...
  337. * boost::asio::socket_base::reuse_address option(true);
  338. * acceptor.set_option(option);
  339. * @endcode
  340. *
  341. * @par
  342. * Getting the current option value:
  343. * @code
  344. * boost::asio::ip::tcp::acceptor acceptor(io_service);
  345. * ...
  346. * boost::asio::socket_base::reuse_address option;
  347. * acceptor.get_option(option);
  348. * bool is_set = option.value();
  349. * @endcode
  350. *
  351. * @par Concepts:
  352. * Socket_Option, Boolean_Socket_Option.
  353. */
  354. #if defined(GENERATING_DOCUMENTATION)
  355. typedef implementation_defined reuse_address;
  356. #else
  357. typedef boost::asio::detail::socket_option::boolean<
  358. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_REUSEADDR)>
  359. reuse_address;
  360. #endif
  361. /// Socket option to specify whether the socket lingers on close if unsent
  362. /// data is present.
  363. /**
  364. * Implements the SOL_SOCKET/SO_LINGER socket option.
  365. *
  366. * @par Examples
  367. * Setting the option:
  368. * @code
  369. * boost::asio::ip::tcp::socket socket(io_service);
  370. * ...
  371. * boost::asio::socket_base::linger option(true, 30);
  372. * socket.set_option(option);
  373. * @endcode
  374. *
  375. * @par
  376. * Getting the current option value:
  377. * @code
  378. * boost::asio::ip::tcp::socket socket(io_service);
  379. * ...
  380. * boost::asio::socket_base::linger option;
  381. * socket.get_option(option);
  382. * bool is_set = option.enabled();
  383. * unsigned short timeout = option.timeout();
  384. * @endcode
  385. *
  386. * @par Concepts:
  387. * Socket_Option, Linger_Socket_Option.
  388. */
  389. #if defined(GENERATING_DOCUMENTATION)
  390. typedef implementation_defined linger;
  391. #else
  392. typedef boost::asio::detail::socket_option::linger<
  393. BOOST_ASIO_OS_DEF(SOL_SOCKET), BOOST_ASIO_OS_DEF(SO_LINGER)>
  394. linger;
  395. #endif
  396. /// Socket option to report aborted connections on accept.
  397. /**
  398. * Implements a custom socket option that determines whether or not an accept
  399. * operation is permitted to fail with boost::asio::error::connection_aborted.
  400. * By default the option is false.
  401. *
  402. * @par Examples
  403. * Setting the option:
  404. * @code
  405. * boost::asio::ip::tcp::acceptor acceptor(io_service);
  406. * ...
  407. * boost::asio::socket_base::enable_connection_aborted option(true);
  408. * acceptor.set_option(option);
  409. * @endcode
  410. *
  411. * @par
  412. * Getting the current option value:
  413. * @code
  414. * boost::asio::ip::tcp::acceptor acceptor(io_service);
  415. * ...
  416. * boost::asio::socket_base::enable_connection_aborted option;
  417. * acceptor.get_option(option);
  418. * bool is_set = option.value();
  419. * @endcode
  420. *
  421. * @par Concepts:
  422. * Socket_Option, Boolean_Socket_Option.
  423. */
  424. #if defined(GENERATING_DOCUMENTATION)
  425. typedef implementation_defined enable_connection_aborted;
  426. #else
  427. typedef boost::asio::detail::socket_option::boolean<
  428. boost::asio::detail::custom_socket_option_level,
  429. boost::asio::detail::enable_connection_aborted_option>
  430. enable_connection_aborted;
  431. #endif
  432. /// (Deprecated: Use non_blocking().) IO control command to
  433. /// set the blocking mode of the socket.
  434. /**
  435. * Implements the FIONBIO IO control command.
  436. *
  437. * @par Example
  438. * @code
  439. * boost::asio::ip::tcp::socket socket(io_service);
  440. * ...
  441. * boost::asio::socket_base::non_blocking_io command(true);
  442. * socket.io_control(command);
  443. * @endcode
  444. *
  445. * @par Concepts:
  446. * IO_Control_Command, Boolean_IO_Control_Command.
  447. */
  448. #if defined(GENERATING_DOCUMENTATION)
  449. typedef implementation_defined non_blocking_io;
  450. #else
  451. typedef boost::asio::detail::io_control::non_blocking_io non_blocking_io;
  452. #endif
  453. /// IO control command to get the amount of data that can be read without
  454. /// blocking.
  455. /**
  456. * Implements the FIONREAD IO control command.
  457. *
  458. * @par Example
  459. * @code
  460. * boost::asio::ip::tcp::socket socket(io_service);
  461. * ...
  462. * boost::asio::socket_base::bytes_readable command(true);
  463. * socket.io_control(command);
  464. * std::size_t bytes_readable = command.get();
  465. * @endcode
  466. *
  467. * @par Concepts:
  468. * IO_Control_Command, Size_IO_Control_Command.
  469. */
  470. #if defined(GENERATING_DOCUMENTATION)
  471. typedef implementation_defined bytes_readable;
  472. #else
  473. typedef boost::asio::detail::io_control::bytes_readable bytes_readable;
  474. #endif
  475. /// The maximum length of the queue of pending incoming connections.
  476. #if defined(GENERATING_DOCUMENTATION)
  477. static const int max_connections = implementation_defined;
  478. #else
  479. BOOST_ASIO_STATIC_CONSTANT(int, max_connections
  480. = BOOST_ASIO_OS_DEF(SOMAXCONN));
  481. #endif
  482. protected:
  483. /// Protected destructor to prevent deletion through this type.
  484. ~socket_base()
  485. {
  486. }
  487. };
  488. } // namespace asio
  489. } // namespace boost
  490. #include <boost/asio/detail/pop_options.hpp>
  491. #endif // BOOST_ASIO_SOCKET_BASE_HPP