5 // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_IP_UDP_HPP
12 #define BOOST_ASIO_IP_UDP_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/basic_datagram_socket.hpp>
20 #include <boost/asio/detail/socket_types.hpp>
21 #include <boost/asio/ip/basic_endpoint.hpp>
22 #include <boost/asio/ip/basic_resolver.hpp>
23 #include <boost/asio/ip/basic_resolver_iterator.hpp>
24 #include <boost/asio/ip/basic_resolver_query.hpp>
26 #include <boost/asio/detail/push_options.hpp>
32 /// Encapsulates the flags needed for UDP.
34 * The boost::asio::ip::udp class contains flags necessary for UDP sockets.
37 * @e Distinct @e objects: Safe.@n
38 * @e Shared @e objects: Safe.
41 * Protocol, InternetProtocol.
46 /// The type of a UDP endpoint.
47 typedef basic_endpoint<udp> endpoint;
49 /// Construct to represent the IPv4 UDP protocol.
52 return udp(BOOST_ASIO_OS_DEF(AF_INET));
55 /// Construct to represent the IPv6 UDP protocol.
58 return udp(BOOST_ASIO_OS_DEF(AF_INET6));
61 /// Obtain an identifier for the type of the protocol.
64 return BOOST_ASIO_OS_DEF(SOCK_DGRAM);
67 /// Obtain an identifier for the protocol.
70 return BOOST_ASIO_OS_DEF(IPPROTO_UDP);
73 /// Obtain an identifier for the protocol family.
79 /// The UDP socket type.
80 typedef basic_datagram_socket<udp> socket;
82 /// The UDP resolver type.
83 typedef basic_resolver<udp> resolver;
85 /// Compare two protocols for equality.
86 friend bool operator==(const udp& p1, const udp& p2)
88 return p1.family_ == p2.family_;
91 /// Compare two protocols for inequality.
92 friend bool operator!=(const udp& p1, const udp& p2)
94 return p1.family_ != p2.family_;
98 // Construct with a specific family.
99 explicit udp(int protocol_family)
100 : family_(protocol_family)
111 #include <boost/asio/detail/pop_options.hpp>
113 #endif // BOOST_ASIO_IP_UDP_HPP