stream_protocol.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // local/stream_protocol.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 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_LOCAL_STREAM_PROTOCOL_HPP
  11. #define BOOST_ASIO_LOCAL_STREAM_PROTOCOL_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_LOCAL_SOCKETS) \
  17. || defined(GENERATING_DOCUMENTATION)
  18. #include <boost/asio/basic_socket_acceptor.hpp>
  19. #include <boost/asio/basic_socket_iostream.hpp>
  20. #include <boost/asio/basic_stream_socket.hpp>
  21. #include <boost/asio/detail/socket_types.hpp>
  22. #include <boost/asio/local/basic_endpoint.hpp>
  23. #include <boost/asio/detail/push_options.hpp>
  24. namespace boost {
  25. namespace asio {
  26. namespace local {
  27. /// Encapsulates the flags needed for stream-oriented UNIX sockets.
  28. /**
  29. * The boost::asio::local::stream_protocol class contains flags necessary for
  30. * stream-oriented UNIX domain sockets.
  31. *
  32. * @par Thread Safety
  33. * @e Distinct @e objects: Safe.@n
  34. * @e Shared @e objects: Safe.
  35. *
  36. * @par Concepts:
  37. * Protocol.
  38. */
  39. class stream_protocol
  40. {
  41. public:
  42. /// Obtain an identifier for the type of the protocol.
  43. int type() const
  44. {
  45. return SOCK_STREAM;
  46. }
  47. /// Obtain an identifier for the protocol.
  48. int protocol() const
  49. {
  50. return 0;
  51. }
  52. /// Obtain an identifier for the protocol family.
  53. int family() const
  54. {
  55. return AF_UNIX;
  56. }
  57. /// The type of a UNIX domain endpoint.
  58. typedef basic_endpoint<stream_protocol> endpoint;
  59. /// The UNIX domain socket type.
  60. typedef basic_stream_socket<stream_protocol> socket;
  61. /// The UNIX domain acceptor type.
  62. typedef basic_socket_acceptor<stream_protocol> acceptor;
  63. #if !defined(BOOST_ASIO_NO_IOSTREAM)
  64. /// The UNIX domain iostream type.
  65. typedef basic_socket_iostream<stream_protocol> iostream;
  66. #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
  67. };
  68. } // namespace local
  69. } // namespace asio
  70. } // namespace boost
  71. #include <boost/asio/detail/pop_options.hpp>
  72. #endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
  73. // || defined(GENERATING_DOCUMENTATION)
  74. #endif // BOOST_ASIO_LOCAL_STREAM_PROTOCOL_HPP