diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-09-10 17:05:39 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-10-09 13:36:32 +0200 |
commit | 6029d50080bb795524d6cefe8d6b4b9b88475bdd (patch) | |
tree | 4916afbcaf13ae844c38d5143644533f1bae3053 | |
parent | 2fe9dca45f7d0a519fef5053ba61e2db7c1ff2b1 (diff) | |
download | tigervnc-6029d50080bb795524d6cefe8d6b4b9b88475bdd.tar.gz tigervnc-6029d50080bb795524d6cefe8d6b4b9b88475bdd.zip |
Move SocketException to rdr
Socket APIs are used in more places than the abstraction in
common/network. Make it easier to use this exception class by putting
it in a more common place.
-rw-r--r-- | common/network/Socket.cxx | 6 | ||||
-rw-r--r-- | common/network/Socket.h | 5 | ||||
-rw-r--r-- | common/rdr/Exception.h | 4 |
3 files changed, 7 insertions, 8 deletions
diff --git a/common/network/Socket.cxx b/common/network/Socket.cxx index 8da44366..8bb96763 100644 --- a/common/network/Socket.cxx +++ b/common/network/Socket.cxx @@ -53,7 +53,7 @@ void network::initSockets() { WSADATA initResult; if (WSAStartup(requiredVersion, &initResult) != 0) - throw SocketException("unable to initialise Winsock2", errorNumber); + throw rdr::SocketException("unable to initialise Winsock2", errorNumber); #else signal(SIGPIPE, SIG_IGN); #endif @@ -161,7 +161,7 @@ Socket* SocketListener::accept() { // Accept an incoming connection if ((new_sock = ::accept(fd, nullptr, nullptr)) < 0) - throw SocketException("unable to accept new connection", errorNumber); + throw rdr::SocketException("unable to accept new connection", errorNumber); // Create the socket object & check connection is allowed Socket* s = createSocket(new_sock); @@ -179,7 +179,7 @@ void SocketListener::listen(int sock) if (::listen(sock, 5) < 0) { int e = errorNumber; closesocket(sock); - throw SocketException("unable to set socket to listening mode", e); + throw rdr::SocketException("unable to set socket to listening mode", e); } fd = sock; diff --git a/common/network/Socket.h b/common/network/Socket.h index 7085d73a..34b8db8e 100644 --- a/common/network/Socket.h +++ b/common/network/Socket.h @@ -26,7 +26,6 @@ #include <limits.h> #include <rdr/FdInStream.h> #include <rdr/FdOutStream.h> -#include <rdr/Exception.h> namespace network { @@ -107,10 +106,6 @@ namespace network { ConnectionFilter* filter; }; - struct SocketException : public rdr::SystemException { - SocketException(const char* text, int err_) : rdr::SystemException(text, err_) {} - }; - } #endif // __NETWORK_SOCKET_H__ diff --git a/common/rdr/Exception.h b/common/rdr/Exception.h index f1a167e5..1202c37c 100644 --- a/common/rdr/Exception.h +++ b/common/rdr/Exception.h @@ -37,6 +37,10 @@ namespace rdr { SystemException(const char* s, int err_); }; + struct SocketException : public SystemException { + SocketException(const char* text, int err_) : SystemException(text, err_) {} + }; + struct GAIException : public Exception { int err; GAIException(const char* s, int err_); |