datagram_protocol.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // local/datagram_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_DATAGRAM_PROTOCOL_HPP
  11. #define BOOST_ASIO_LOCAL_DATAGRAM_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_datagram_socket.hpp>
  19. #include <boost/asio/detail/socket_types.hpp>
  20. #include <boost/asio/local/basic_endpoint.hpp>
  21. #include <boost/asio/detail/push_options.hpp>
  22. namespace boost {
  23. namespace asio {
  24. namespace local {
  25. /// Encapsulates the flags needed for datagram-oriented UNIX sockets.
  26. /**
  27. * The boost::asio::local::datagram_protocol class contains flags necessary for
  28. * datagram-oriented UNIX domain sockets.
  29. *
  30. * @par Thread Safety
  31. * @e Distinct @e objects: Safe.@n
  32. * @e Shared @e objects: Safe.
  33. *
  34. * @par Concepts:
  35. * Protocol.
  36. */
  37. class datagram_protocol
  38. {
  39. public:
  40. /// Obtain an identifier for the type of the protocol.
  41. int type() const
  42. {
  43. return SOCK_DGRAM;
  44. }
  45. /// Obtain an identifier for the protocol.
  46. int protocol() const
  47. {
  48. return 0;
  49. }
  50. /// Obtain an identifier for the protocol family.
  51. int family() const
  52. {
  53. return AF_UNIX;
  54. }
  55. /// The type of a UNIX domain endpoint.
  56. typedef basic_endpoint<datagram_protocol> endpoint;
  57. /// The UNIX domain socket type.
  58. typedef basic_datagram_socket<datagram_protocol> socket;
  59. };
  60. } // namespace local
  61. } // namespace asio
  62. } // namespace boost
  63. #include <boost/asio/detail/pop_options.hpp>
  64. #endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
  65. // || defined(GENERATING_DOCUMENTATION)
  66. #endif // BOOST_ASIO_LOCAL_DATAGRAM_PROTOCOL_HPP