]> git.tdb.fi Git - libs/net.git/blobdiff - source/streamlistensocket.cpp
Exception changes
[libs/net.git] / source / streamlistensocket.cpp
index ccb683a1a31937b18b46db991aad021ea6b8fec8..693f3040dc85c0a81dcc1bd6b8271dea8a91f88a 100644 (file)
@@ -1,9 +1,12 @@
 #include <cerrno>
 #include <msp/core/refptr.h>
+#include <msp/core/systemerror.h>
 #include <msp/strings/format.h>
 #include "streamlistensocket.h"
 #include "streamsocket.h"
 
+using namespace std;
+
 namespace Msp {
 namespace Net {
 
@@ -14,7 +17,8 @@ StreamListenSocket::StreamListenSocket(Family af, int proto):
 
 int StreamListenSocket::connect(const SockAddr &)
 {
-       throw Exception("Can't connect a listen socket");
+       // XXX This function needs to go away
+       throw logic_error("Can't connect a listen socket");
 }
 
 void StreamListenSocket::listen(const SockAddr &addr, unsigned backlog)
@@ -23,7 +27,7 @@ void StreamListenSocket::listen(const SockAddr &addr, unsigned backlog)
 
        int err = ::listen(handle, backlog);
        if(err==-1)
-               throw SystemError("Unable to listen", errno);
+               throw system_error("listen");
 
 #ifdef WIN32
        WSAEventSelect(handle, event, FD_ACCEPT);
@@ -36,7 +40,7 @@ void StreamListenSocket::listen(const SockAddr &addr, unsigned backlog)
 StreamSocket *StreamListenSocket::accept()
 {
        if(!listening)
-               throw InvalidState("Socket is not listening");
+               throw bad_socket_state("not listening");
 
        sockaddr_storage sa;
        socklen_t size = sizeof(sockaddr_storage);