seq_packet_protocol.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // local/seq_packet_protocol.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2023 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_LOCAL_SEQ_PACKET_PROTOCOL_HPP
  11. #define ASIO_LOCAL_SEQ_PACKET_PROTOCOL_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_LOCAL_SOCKETS) \
  17. || defined(GENERATING_DOCUMENTATION)
  18. #include "asio/basic_socket_acceptor.hpp"
  19. #include "asio/basic_seq_packet_socket.hpp"
  20. #include "asio/detail/socket_types.hpp"
  21. #include "asio/local/basic_endpoint.hpp"
  22. #include "asio/detail/push_options.hpp"
  23. namespace asio {
  24. namespace local {
  25. /// Encapsulates the flags needed for seq_packet UNIX sockets.
  26. /**
  27. * The asio::local::seq_packet_protocol class contains flags necessary
  28. * for sequenced packet 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 seq_packet_protocol
  38. {
  39. public:
  40. /// Obtain an identifier for the type of the protocol.
  41. int type() const noexcept
  42. {
  43. return SOCK_SEQPACKET;
  44. }
  45. /// Obtain an identifier for the protocol.
  46. int protocol() const noexcept
  47. {
  48. return 0;
  49. }
  50. /// Obtain an identifier for the protocol family.
  51. int family() const noexcept
  52. {
  53. return AF_UNIX;
  54. }
  55. /// The type of a UNIX domain endpoint.
  56. typedef basic_endpoint<seq_packet_protocol> endpoint;
  57. /// The UNIX domain socket type.
  58. typedef basic_seq_packet_socket<seq_packet_protocol> socket;
  59. /// The UNIX domain acceptor type.
  60. typedef basic_socket_acceptor<seq_packet_protocol> acceptor;
  61. };
  62. } // namespace local
  63. } // namespace asio
  64. #include "asio/detail/pop_options.hpp"
  65. #endif // defined(ASIO_HAS_LOCAL_SOCKETS)
  66. // || defined(GENERATING_DOCUMENTATION)
  67. #endif // ASIO_LOCAL_SEQ_PACKET_PROTOCOL_HPP