]> git.tdb.fi Git - libs/net.git/blobdiff - source/streamsocket.cpp
Use SystemError at appropriate places
[libs/net.git] / source / streamsocket.cpp
index cf1a7b535203a1b3b643923d0ca09443e063c5b7..0f69111204af5ee0af783a158217ece68a7ecfa4 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef WIN32
 #include <sys/socket.h>
 #endif
-#include <errno.h>
+#include <cerrno>
 #include <msp/io/poll.h>
 #include <msp/strings/formatter.h>
 #include "streamsocket.h"
@@ -41,7 +41,7 @@ int StreamSocket::poll_connect(const Time::TimeDelta &timeout)
 #ifdef WIN32
                throw Exception(format("Connection polling failed: %d", WSAGetLastError()));
 #else
-               throw Exception(format("Connection polling failed: %s", strerror(errno)));
+               throw SystemError("Connection polling failed", errno);
 #endif
        else if(res>0)
        {
@@ -57,7 +57,7 @@ int StreamSocket::poll_connect(const Time::TimeDelta &timeout)
 #ifdef WIN32
                        throw Exception(format("Connection failed: %d", err));
 #else
-                       throw Exception(format("Connection failed: %s", strerror(err)));
+                       throw SystemError("Connection failed", err);
 #endif
                }
 
@@ -116,7 +116,7 @@ int StreamSocket::connect(const SockAddr &addr)
                        set_events(IO::P_OUTPUT);
                }
                else
-                       throw Exception(format("Unable to connect: %s", strerror(errno)));
+                       throw SystemError("Unable to connect", errno);
        }
 #endif