Which Boost error codes/conditions are returned by which Boost.Asio calls?

 ̄綄美尐妖づ 提交于 2019-12-01 09:44:07

In general, when Boost.Asio depends on the OS implementation, then it will neither specify the conditions under which errors may occur nor the error codes that may be returned. On failure Boost.Asio will populate a boost::system::error_code if the application is capable of receiving it, such as for asynchronous operations or synchronous operation overloads with the error_code parameter; otherwise it will throw an exception containing the error_code. The documentation states the following:

Unless otherwise noted, when the behaviour of an asynchronous operation is defined "as if" implemented by a POSIX function, the handler will be invoked with a value of type error_code that corresponds to the failure condition described by POSIX for that function, if any. Otherwise the handler will be invoked with an implementation-defined error_code value that reflects the operating system error.

Asynchronous operations will not fail with an error condition that indicates interruption by a signal (POSIX EINTR). Asynchronous operations will not fail with any error condition associated with non-blocking operations (POSIX EWOULDBLOCK, EAGAIN or EINPROGRESS; Windows WSAEWOULDBLOCK or WSAEINPROGRESS).

If error handling depends on the exact error code, then one can often use the BSD API mapping documentation to determine which OS calls are being made. One can then use the appropriate OS documentation to determine the conditions for which an error occurs and the values. The mapping between error codes and Boost.Asio error codes is located within asio/error.hpp, but the mapping is normally fairly straight forward.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!