123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- #ifndef BOOST_ASIO_ERROR_HPP
- #define BOOST_ASIO_ERROR_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/push_options.hpp>
- #include <boost/asio/detail/push_options.hpp>
- #include <boost/config.hpp>
- #include <boost/cerrno.hpp>
- #include <boost/system/error_code.hpp>
- #include <boost/asio/detail/pop_options.hpp>
- #include <boost/asio/detail/socket_types.hpp>
- #if defined(GENERATING_DOCUMENTATION)
- # define BOOST_ASIO_NATIVE_ERROR(e) implementation_defined
- # define BOOST_ASIO_SOCKET_ERROR(e) implementation_defined
- # define BOOST_ASIO_NETDB_ERROR(e) implementation_defined
- # define BOOST_ASIO_GETADDRINFO_ERROR(e) implementation_defined
- # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined
- #elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- # define BOOST_ASIO_NATIVE_ERROR(e) e
- # define BOOST_ASIO_SOCKET_ERROR(e) WSA ## e
- # define BOOST_ASIO_NETDB_ERROR(e) WSA ## e
- # define BOOST_ASIO_GETADDRINFO_ERROR(e) WSA ## e
- # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
- #else
- # define BOOST_ASIO_NATIVE_ERROR(e) e
- # define BOOST_ASIO_SOCKET_ERROR(e) e
- # define BOOST_ASIO_NETDB_ERROR(e) e
- # define BOOST_ASIO_GETADDRINFO_ERROR(e) e
- # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix
- #endif
- namespace boost {
- namespace asio {
- namespace error {
- enum basic_errors
- {
-
- access_denied = BOOST_ASIO_SOCKET_ERROR(EACCES),
-
- address_family_not_supported = BOOST_ASIO_SOCKET_ERROR(EAFNOSUPPORT),
-
- address_in_use = BOOST_ASIO_SOCKET_ERROR(EADDRINUSE),
-
- already_connected = BOOST_ASIO_SOCKET_ERROR(EISCONN),
-
- already_started = BOOST_ASIO_SOCKET_ERROR(EALREADY),
-
- broken_pipe = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_BROKEN_PIPE),
- BOOST_ASIO_NATIVE_ERROR(EPIPE)),
-
- connection_aborted = BOOST_ASIO_SOCKET_ERROR(ECONNABORTED),
-
- connection_refused = BOOST_ASIO_SOCKET_ERROR(ECONNREFUSED),
-
- connection_reset = BOOST_ASIO_SOCKET_ERROR(ECONNRESET),
-
- bad_descriptor = BOOST_ASIO_SOCKET_ERROR(EBADF),
-
- fault = BOOST_ASIO_SOCKET_ERROR(EFAULT),
-
- host_unreachable = BOOST_ASIO_SOCKET_ERROR(EHOSTUNREACH),
-
- in_progress = BOOST_ASIO_SOCKET_ERROR(EINPROGRESS),
-
- interrupted = BOOST_ASIO_SOCKET_ERROR(EINTR),
-
- invalid_argument = BOOST_ASIO_SOCKET_ERROR(EINVAL),
-
- message_size = BOOST_ASIO_SOCKET_ERROR(EMSGSIZE),
-
- name_too_long = BOOST_ASIO_SOCKET_ERROR(ENAMETOOLONG),
-
- network_down = BOOST_ASIO_SOCKET_ERROR(ENETDOWN),
-
- network_reset = BOOST_ASIO_SOCKET_ERROR(ENETRESET),
-
- network_unreachable = BOOST_ASIO_SOCKET_ERROR(ENETUNREACH),
-
- no_descriptors = BOOST_ASIO_SOCKET_ERROR(EMFILE),
-
- no_buffer_space = BOOST_ASIO_SOCKET_ERROR(ENOBUFS),
-
- no_memory = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
- BOOST_ASIO_NATIVE_ERROR(ENOMEM)),
-
- no_permission = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
- BOOST_ASIO_NATIVE_ERROR(EPERM)),
-
- no_protocol_option = BOOST_ASIO_SOCKET_ERROR(ENOPROTOOPT),
-
- not_connected = BOOST_ASIO_SOCKET_ERROR(ENOTCONN),
-
- not_socket = BOOST_ASIO_SOCKET_ERROR(ENOTSOCK),
-
- operation_aborted = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
- BOOST_ASIO_NATIVE_ERROR(ECANCELED)),
-
- operation_not_supported = BOOST_ASIO_SOCKET_ERROR(EOPNOTSUPP),
-
- shut_down = BOOST_ASIO_SOCKET_ERROR(ESHUTDOWN),
-
- timed_out = BOOST_ASIO_SOCKET_ERROR(ETIMEDOUT),
-
- try_again = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_RETRY),
- BOOST_ASIO_NATIVE_ERROR(EAGAIN)),
-
- would_block = BOOST_ASIO_SOCKET_ERROR(EWOULDBLOCK)
- };
- enum netdb_errors
- {
-
- host_not_found = BOOST_ASIO_NETDB_ERROR(HOST_NOT_FOUND),
-
- host_not_found_try_again = BOOST_ASIO_NETDB_ERROR(TRY_AGAIN),
-
- no_data = BOOST_ASIO_NETDB_ERROR(NO_DATA),
-
- no_recovery = BOOST_ASIO_NETDB_ERROR(NO_RECOVERY)
- };
- enum addrinfo_errors
- {
-
- service_not_found = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
- BOOST_ASIO_GETADDRINFO_ERROR(EAI_SERVICE)),
-
- socket_type_not_supported = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
- BOOST_ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE))
- };
- enum misc_errors
- {
-
- already_open = 1,
-
- eof,
-
- not_found,
-
- fd_set_failure
- };
- enum ssl_errors
- {
- };
- inline const boost::system::error_category& get_system_category()
- {
- return boost::system::get_system_category();
- }
- #if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
- namespace detail {
- class netdb_category : public boost::system::error_category
- {
- public:
- const char* name() const
- {
- return "asio.netdb";
- }
- std::string message(int value) const
- {
- if (value == error::host_not_found)
- return "Host not found (authoritative)";
- if (value == error::host_not_found_try_again)
- return "Host not found (non-authoritative), try again later";
- if (value == error::no_data)
- return "The query is valid, but it does not have associated data";
- if (value == error::no_recovery)
- return "A non-recoverable error occurred during database lookup";
- return "asio.netdb error";
- }
- };
- }
- inline const boost::system::error_category& get_netdb_category()
- {
- static detail::netdb_category instance;
- return instance;
- }
- namespace detail {
- class addrinfo_category : public boost::system::error_category
- {
- public:
- const char* name() const
- {
- return "asio.addrinfo";
- }
- std::string message(int value) const
- {
- if (value == error::service_not_found)
- return "Service not found";
- if (value == error::socket_type_not_supported)
- return "Socket type not supported";
- return "asio.addrinfo error";
- }
- };
- }
- inline const boost::system::error_category& get_addrinfo_category()
- {
- static detail::addrinfo_category instance;
- return instance;
- }
- #else
- inline const boost::system::error_category& get_netdb_category()
- {
- return get_system_category();
- }
- inline const boost::system::error_category& get_addrinfo_category()
- {
- return get_system_category();
- }
- #endif
- namespace detail {
- class misc_category : public boost::system::error_category
- {
- public:
- const char* name() const
- {
- return "asio.misc";
- }
- std::string message(int value) const
- {
- if (value == error::already_open)
- return "Already open";
- if (value == error::eof)
- return "End of file";
- if (value == error::not_found)
- return "Element not found";
- if (value == error::fd_set_failure)
- return "The descriptor does not fit into the select call's fd_set";
- return "asio.misc error";
- }
- };
- }
- inline const boost::system::error_category& get_misc_category()
- {
- static detail::misc_category instance;
- return instance;
- }
- namespace detail {
- class ssl_category : public boost::system::error_category
- {
- public:
- const char* name() const
- {
- return "asio.ssl";
- }
- std::string message(int) const
- {
- return "asio.ssl error";
- }
- };
- }
- inline const boost::system::error_category& get_ssl_category()
- {
- static detail::ssl_category instance;
- return instance;
- }
- static const boost::system::error_category& system_category
- = boost::asio::error::get_system_category();
- static const boost::system::error_category& netdb_category
- = boost::asio::error::get_netdb_category();
- static const boost::system::error_category& addrinfo_category
- = boost::asio::error::get_addrinfo_category();
- static const boost::system::error_category& misc_category
- = boost::asio::error::get_misc_category();
- static const boost::system::error_category& ssl_category
- = boost::asio::error::get_ssl_category();
- }
- }
- namespace system {
- template<> struct is_error_code_enum<boost::asio::error::basic_errors>
- {
- static const bool value = true;
- };
- template<> struct is_error_code_enum<boost::asio::error::netdb_errors>
- {
- static const bool value = true;
- };
- template<> struct is_error_code_enum<boost::asio::error::addrinfo_errors>
- {
- static const bool value = true;
- };
- template<> struct is_error_code_enum<boost::asio::error::misc_errors>
- {
- static const bool value = true;
- };
- template<> struct is_error_code_enum<boost::asio::error::ssl_errors>
- {
- static const bool value = true;
- };
- }
- namespace asio {
- namespace error {
- inline boost::system::error_code make_error_code(basic_errors e)
- {
- return boost::system::error_code(
- static_cast<int>(e), get_system_category());
- }
- inline boost::system::error_code make_error_code(netdb_errors e)
- {
- return boost::system::error_code(
- static_cast<int>(e), get_netdb_category());
- }
- inline boost::system::error_code make_error_code(addrinfo_errors e)
- {
- return boost::system::error_code(
- static_cast<int>(e), get_addrinfo_category());
- }
- inline boost::system::error_code make_error_code(misc_errors e)
- {
- return boost::system::error_code(
- static_cast<int>(e), get_misc_category());
- }
- inline boost::system::error_code make_error_code(ssl_errors e)
- {
- return boost::system::error_code(
- static_cast<int>(e), get_ssl_category());
- }
- }
- }
- }
- #undef BOOST_ASIO_NATIVE_ERROR
- #undef BOOST_ASIO_SOCKET_ERROR
- #undef BOOST_ASIO_NETDB_ERROR
- #undef BOOST_ASIO_GETADDRINFO_ERROR
- #undef BOOST_ASIO_WIN_OR_POSIX
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|