Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
2.3KB

  1. //
  2. // ip/udp.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_IP_UDP_HPP
  11. #define ASIO_IP_UDP_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. #include "asio/basic_datagram_socket.hpp"
  17. #include "asio/detail/socket_types.hpp"
  18. #include "asio/ip/basic_endpoint.hpp"
  19. #include "asio/ip/basic_resolver.hpp"
  20. #include "asio/ip/basic_resolver_iterator.hpp"
  21. #include "asio/ip/basic_resolver_query.hpp"
  22. #include "asio/detail/push_options.hpp"
  23. namespace asio {
  24. namespace ip {
  25. /// Encapsulates the flags needed for UDP.
  26. /**
  27. * The asio::ip::udp class contains flags necessary for UDP sockets.
  28. *
  29. * @par Thread Safety
  30. * @e Distinct @e objects: Safe.@n
  31. * @e Shared @e objects: Safe.
  32. *
  33. * @par Concepts:
  34. * Protocol, InternetProtocol.
  35. */
  36. class udp
  37. {
  38. public:
  39. /// The type of a UDP endpoint.
  40. typedef basic_endpoint<udp> endpoint;
  41. /// Construct to represent the IPv4 UDP protocol.
  42. static udp v4()
  43. {
  44. return udp(ASIO_OS_DEF(AF_INET));
  45. }
  46. /// Construct to represent the IPv6 UDP protocol.
  47. static udp v6()
  48. {
  49. return udp(ASIO_OS_DEF(AF_INET6));
  50. }
  51. /// Obtain an identifier for the type of the protocol.
  52. int type() const
  53. {
  54. return ASIO_OS_DEF(SOCK_DGRAM);
  55. }
  56. /// Obtain an identifier for the protocol.
  57. int protocol() const
  58. {
  59. return ASIO_OS_DEF(IPPROTO_UDP);
  60. }
  61. /// Obtain an identifier for the protocol family.
  62. int family() const
  63. {
  64. return family_;
  65. }
  66. /// The UDP socket type.
  67. typedef basic_datagram_socket<udp> socket;
  68. /// The UDP resolver type.
  69. typedef basic_resolver<udp> resolver;
  70. /// Compare two protocols for equality.
  71. friend bool operator==(const udp& p1, const udp& p2)
  72. {
  73. return p1.family_ == p2.family_;
  74. }
  75. /// Compare two protocols for inequality.
  76. friend bool operator!=(const udp& p1, const udp& p2)
  77. {
  78. return p1.family_ != p2.family_;
  79. }
  80. private:
  81. // Construct with a specific family.
  82. explicit udp(int protocol_family)
  83. : family_(protocol_family)
  84. {
  85. }
  86. int family_;
  87. };
  88. } // namespace ip
  89. } // namespace asio
  90. #include "asio/detail/pop_options.hpp"
  91. #endif // ASIO_IP_UDP_HPP