]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/socketengine.h
Merge pull request #1018 from SaberUK/insp20+hidekills
[user/henk/code/inspircd.git] / include / socketengine.h
index b790f6d77596b389bab0862b1b35aa8754ae0797..37b7d637350b833e46d38f13d932f253008f36d6 100644 (file)
@@ -489,8 +489,34 @@ public:
        /** Get data transfer statistics, kilobits per second in and out and total.
         */
        void GetStats(float &kbitpersec_in, float &kbitpersec_out, float &kbitpersec_total);
+
+       /** Should we ignore the error in errno?
+        * Checks EAGAIN and WSAEWOULDBLOCK
+        */
+       static bool IgnoreError();
+
+       /** Return the last socket related error. strrerror(errno) on *nix
+        */
+       static std::string LastError();
+
+       /** Returns the error for the given error num, strerror(errnum) on *nix
+        */
+       static std::string GetError(int errnum);
 };
 
+inline bool SocketEngine::IgnoreError()
+{
+       if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
+               return true;
+
+#ifdef _WIN32
+       if (WSAGetLastError() == WSAEWOULDBLOCK)
+               return true;
+#endif
+
+       return false;
+}
+
 SocketEngine* CreateSocketEngine();
 
 #endif