descriptor_base.hpp 2.5 KB

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