diff options
author | unknown <sustrik@.(none)> | 2009-10-01 13:48:04 +0200 |
---|---|---|
committer | unknown <sustrik@.(none)> | 2009-10-01 13:48:04 +0200 |
commit | 49a9ef5fcb661827ee174415b4608e609bd0a65b (patch) | |
tree | e487422695b0b4774d42569b1fbbfa1e6a848206 /src/err.cpp | |
parent | cc631c4c6649b0d67114db13386a949426e35dbf (diff) |
windows error handling improved
Diffstat (limited to 'src/err.cpp')
-rw-r--r-- | src/err.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/err.cpp b/src/err.cpp index ef5b987..36cb2fc 100644 --- a/src/err.cpp +++ b/src/err.cpp @@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "../bindings/c/zmq.h" + #include "err.hpp" #include "platform.hpp" @@ -24,8 +26,6 @@ const char *zmq::wsa_error() { - - int errcode = WSAGetLastError (); // TODO: This is not a generic way to handle this... if (errcode == WSAEWOULDBLOCK) @@ -148,4 +148,43 @@ void zmq::win_error (char *buffer_, size_t buffer_size_) zmq_assert (rc); } +void zmq::wsa_error_to_errno () +{ + int errcode = WSAGetLastError (); + switch (errcode) { + case WSAEINPROGRESS: + errno = EAGAIN; + return; + case WSAEBADF: + errno = EBADF; + return; + case WSAEINVAL: + errno = EINVAL; + return; + case WSAEMFILE: + errno = EMFILE; + return; + case WSAEFAULT: + errno = EFAULT; + return; + case WSAEPROTONOSUPPORT: + errno = EPROTONOSUPPORT; + return; + case WSAENOBUFS: + errno = ENOBUFS; + return; + case WSAENETDOWN: + errno = ENETDOWN; + return; + case WSAEADDRINUSE: + errno = EADDRINUSE; + return; + case WSAEADDRNOTAVAIL: + errno = EADDRNOTAVAIL; + return; + default: + wsa_assert (false); + } +} + #endif |