summaryrefslogtreecommitdiff
path: root/src/err.cpp
diff options
context:
space:
mode:
authormalosek <malosek@fastmq.com>2009-10-05 10:22:31 +0200
committermalosek <malosek@fastmq.com>2009-10-05 10:22:31 +0200
commitd57ee0984ac3f8712063a7f83d7200be25ca5513 (patch)
treea956443e70c48ebd21242c11cc015db61c53c682 /src/err.cpp
parentff65e26ce7567ea6a907e566f8530f4988231d68 (diff)
parent4efe2366d7394e8969fc9aa64c50be6842d8455f (diff)
Merge branch 'master' of git@github.com:sustrik/zeromq2
Diffstat (limited to 'src/err.cpp')
-rw-r--r--src/err.cpp43
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