descriptor_base.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // descriptor_base.hpp
  3. // ~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2010 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/push_options.hpp"
  16. #include "asio/detail/push_options.hpp"
  17. #include <boost/config.hpp>
  18. #include <boost/detail/workaround.hpp>
  19. #include "asio/detail/pop_options.hpp"
  20. #include "asio/detail/io_control.hpp"
  21. #include "asio/detail/socket_option.hpp"
  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. /// IO control command to set the blocking 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 // ASIO_POSIX_DESCRIPTOR_BASE_HPP