descriptor_base.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // posix/descriptor_base.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2013 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_POSIX_DESCRIPTOR_BASE_HPP
  11. #define BOOST_ASIO_POSIX_DESCRIPTOR_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. #if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \
  17. || defined(GENERATING_DOCUMENTATION)
  18. #include <boost/asio/detail/io_control.hpp>
  19. #include <boost/asio/detail/socket_option.hpp>
  20. #include <boost/asio/detail/push_options.hpp>
  21. namespace boost {
  22. namespace asio {
  23. namespace posix {
  24. /// The descriptor_base class is used as a base for the basic_stream_descriptor
  25. /// class template so that we have a common place to define the associated
  26. /// IO control commands.
  27. class descriptor_base
  28. {
  29. public:
  30. /// (Deprecated: Use non_blocking().) IO control command to set the blocking
  31. /// mode of the descriptor.
  32. /**
  33. * Implements the FIONBIO IO control command.
  34. *
  35. * @par Example
  36. * @code
  37. * boost::asio::posix::stream_descriptor descriptor(io_service);
  38. * ...
  39. * boost::asio::descriptor_base::non_blocking_io command(true);
  40. * descriptor.io_control(command);
  41. * @endcode
  42. *
  43. * @par Concepts:
  44. * IoControlCommand.
  45. */
  46. #if defined(GENERATING_DOCUMENTATION)
  47. typedef implementation_defined non_blocking_io;
  48. #else
  49. typedef boost::asio::detail::io_control::non_blocking_io non_blocking_io;
  50. #endif
  51. /// IO control command to get the amount of data that can be read without
  52. /// blocking.
  53. /**
  54. * Implements the FIONREAD IO control command.
  55. *
  56. * @par Example
  57. * @code
  58. * boost::asio::posix::stream_descriptor descriptor(io_service);
  59. * ...
  60. * boost::asio::descriptor_base::bytes_readable command(true);
  61. * descriptor.io_control(command);
  62. * std::size_t bytes_readable = command.get();
  63. * @endcode
  64. *
  65. * @par Concepts:
  66. * IoControlCommand.
  67. */
  68. #if defined(GENERATING_DOCUMENTATION)
  69. typedef implementation_defined bytes_readable;
  70. #else
  71. typedef boost::asio::detail::io_control::bytes_readable bytes_readable;
  72. #endif
  73. protected:
  74. /// Protected destructor to prevent deletion through this type.
  75. ~descriptor_base()
  76. {
  77. }
  78. };
  79. } // namespace posix
  80. } // namespace asio
  81. } // namespace boost
  82. #include <boost/asio/detail/pop_options.hpp>
  83. #endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
  84. // || defined(GENERATING_DOCUMENTATION)
  85. #endif // BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP