123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- #ifndef BOOST_ASIO_IP_DETAIL_ENDPOINT_HPP
- #define BOOST_ASIO_IP_DETAIL_ENDPOINT_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <string>
- #include <boost/asio/detail/socket_types.hpp>
- #include <boost/asio/detail/winsock_init.hpp>
- #include <boost/system/error_code.hpp>
- #include <boost/asio/ip/address.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace ip {
- namespace detail {
- class endpoint
- {
- public:
-
- BOOST_ASIO_DECL endpoint() BOOST_ASIO_NOEXCEPT;
-
- BOOST_ASIO_DECL endpoint(int family,
- unsigned short port_num) BOOST_ASIO_NOEXCEPT;
-
- BOOST_ASIO_DECL endpoint(const boost::asio::ip::address& addr,
- unsigned short port_num) BOOST_ASIO_NOEXCEPT;
-
- endpoint(const endpoint& other) BOOST_ASIO_NOEXCEPT
- : data_(other.data_)
- {
- }
-
- endpoint& operator=(const endpoint& other) BOOST_ASIO_NOEXCEPT
- {
- data_ = other.data_;
- return *this;
- }
-
- boost::asio::detail::socket_addr_type* data() BOOST_ASIO_NOEXCEPT
- {
- return &data_.base;
- }
-
- const boost::asio::detail::socket_addr_type* data() const BOOST_ASIO_NOEXCEPT
- {
- return &data_.base;
- }
-
- std::size_t size() const BOOST_ASIO_NOEXCEPT
- {
- if (is_v4())
- return sizeof(boost::asio::detail::sockaddr_in4_type);
- else
- return sizeof(boost::asio::detail::sockaddr_in6_type);
- }
-
- BOOST_ASIO_DECL void resize(std::size_t new_size);
-
- std::size_t capacity() const BOOST_ASIO_NOEXCEPT
- {
- return sizeof(data_);
- }
-
- BOOST_ASIO_DECL unsigned short port() const BOOST_ASIO_NOEXCEPT;
-
- BOOST_ASIO_DECL void port(unsigned short port_num) BOOST_ASIO_NOEXCEPT;
-
- BOOST_ASIO_DECL boost::asio::ip::address address() const BOOST_ASIO_NOEXCEPT;
-
- BOOST_ASIO_DECL void address(
- const boost::asio::ip::address& addr) BOOST_ASIO_NOEXCEPT;
-
- BOOST_ASIO_DECL friend bool operator==(const endpoint& e1,
- const endpoint& e2) BOOST_ASIO_NOEXCEPT;
-
- BOOST_ASIO_DECL friend bool operator<(const endpoint& e1,
- const endpoint& e2) BOOST_ASIO_NOEXCEPT;
-
- bool is_v4() const BOOST_ASIO_NOEXCEPT
- {
- return data_.base.sa_family == BOOST_ASIO_OS_DEF(AF_INET);
- }
- #if !defined(BOOST_ASIO_NO_IOSTREAM)
-
- BOOST_ASIO_DECL std::string to_string() const;
- #endif
- private:
-
- union data_union
- {
- boost::asio::detail::socket_addr_type base;
- boost::asio::detail::sockaddr_in4_type v4;
- boost::asio::detail::sockaddr_in6_type v6;
- } data_;
- };
- }
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #if defined(BOOST_ASIO_HEADER_ONLY)
- # include <boost/asio/ip/detail/impl/endpoint.ipp>
- #endif
- #endif
|