diff options
author | Mike Buland <eichlan@xagasoft.com> | 2008-10-01 16:46:32 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2008-10-01 16:46:32 +0000 |
commit | d872f7e07c5367f251cf5ebb70a03916251f5306 (patch) | |
tree | 2140986825705e4b6bf35eba8dd556be772888ff /src/serversocket.cpp | |
parent | 467c255511749f018c4572017c9e0e87275524ac (diff) | |
download | libbu++-d872f7e07c5367f251cf5ebb70a03916251f5306.tar.gz libbu++-d872f7e07c5367f251cf5ebb70a03916251f5306.tar.bz2 libbu++-d872f7e07c5367f251cf5ebb70a03916251f5306.tar.xz libbu++-d872f7e07c5367f251cf5ebb70a03916251f5306.zip |
Ok, NIDS is getting better and better, and I went ahead and cleaned up some
exception related code that's been annoying me. You should no longer have to
include any exception header explicitly for normal operations, every class that
has it's own exception to throw defines it in it's own headers.
This may break some code that uses libbu++, but it's an easy fix, just delete
the include for exceptions.h. Sometime soon I would also like to move from
Bu::ExceptionBase to Bu::Exception, but that will affect a lot more code than
this change did.
Diffstat (limited to 'src/serversocket.cpp')
-rw-r--r-- | src/serversocket.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/serversocket.cpp b/src/serversocket.cpp index 30f584d..6f7fc00 100644 --- a/src/serversocket.cpp +++ b/src/serversocket.cpp | |||
@@ -18,9 +18,10 @@ | |||
18 | #include <netdb.h> | 18 | #include <netdb.h> |
19 | #include <arpa/inet.h> | 19 | #include <arpa/inet.h> |
20 | #include <fcntl.h> | 20 | #include <fcntl.h> |
21 | #include "serversocket.h" | 21 | #include "bu/serversocket.h" |
22 | #include "exceptions.h" | 22 | #include "bu/osx_compatibility.h" |
23 | #include "osx_compatibility.h" | 23 | |
24 | namespace Bu { subExceptionDef( ServerSocketException ) } | ||
24 | 25 | ||
25 | Bu::ServerSocket::ServerSocket( int nPort, int nPoolSize ) : | 26 | Bu::ServerSocket::ServerSocket( int nPort, int nPoolSize ) : |
26 | nPort( nPort ) | 27 | nPort( nPort ) |
@@ -64,7 +65,7 @@ void Bu::ServerSocket::startServer( struct sockaddr_in &name, int nPoolSize ) | |||
64 | nServer = socket( PF_INET, SOCK_STREAM, 0 ); | 65 | nServer = socket( PF_INET, SOCK_STREAM, 0 ); |
65 | if( nServer < 0 ) | 66 | if( nServer < 0 ) |
66 | { | 67 | { |
67 | throw Bu::SocketException("Couldn't create a listen socket."); | 68 | throw Bu::ServerSocketException("Couldn't create a listen socket."); |
68 | } | 69 | } |
69 | 70 | ||
70 | int opt = 1; | 71 | int opt = 1; |
@@ -78,12 +79,12 @@ void Bu::ServerSocket::startServer( struct sockaddr_in &name, int nPoolSize ) | |||
78 | 79 | ||
79 | if( bind( nServer, (struct sockaddr *) &name, sizeof(name) ) < 0 ) | 80 | if( bind( nServer, (struct sockaddr *) &name, sizeof(name) ) < 0 ) |
80 | { | 81 | { |
81 | throw Bu::SocketException("Couldn't bind to the listen socket."); | 82 | throw Bu::ServerSocketException("Couldn't bind to the listen socket."); |
82 | } | 83 | } |
83 | 84 | ||
84 | if( listen( nServer, nPoolSize ) < 0 ) | 85 | if( listen( nServer, nPoolSize ) < 0 ) |
85 | { | 86 | { |
86 | throw Bu::SocketException( | 87 | throw Bu::ServerSocketException( |
87 | "Couldn't begin listening to the server socket." | 88 | "Couldn't begin listening to the server socket." |
88 | ); | 89 | ); |
89 | } | 90 | } |
@@ -109,7 +110,7 @@ int Bu::ServerSocket::accept( int nTimeoutSec, int nTimeoutUSec ) | |||
109 | 110 | ||
110 | if( TEMP_FAILURE_RETRY(select( nServer+1, &fdRead, NULL, NULL, &xT )) < 0 ) | 111 | if( TEMP_FAILURE_RETRY(select( nServer+1, &fdRead, NULL, NULL, &xT )) < 0 ) |
111 | { | 112 | { |
112 | throw SocketException( | 113 | throw Bu::ServerSocketException( |
113 | "Error scanning for new connections: %s", strerror( errno ) | 114 | "Error scanning for new connections: %s", strerror( errno ) |
114 | ); | 115 | ); |
115 | } | 116 | } |
@@ -134,7 +135,7 @@ int Bu::ServerSocket::accept( int nTimeoutSec, int nTimeoutUSec ) | |||
134 | #endif /* __CYGWIN__ */ | 135 | #endif /* __CYGWIN__ */ |
135 | if( nClient < 0 ) | 136 | if( nClient < 0 ) |
136 | { | 137 | { |
137 | throw SocketException( | 138 | throw Bu::ServerSocketException( |
138 | "Error accepting a new connection: %s", strerror( errno ) | 139 | "Error accepting a new connection: %s", strerror( errno ) |
139 | ); | 140 | ); |
140 | } | 141 | } |
@@ -150,7 +151,7 @@ int Bu::ServerSocket::accept( int nTimeoutSec, int nTimeoutUSec ) | |||
150 | flags |= O_NONBLOCK; | 151 | flags |= O_NONBLOCK; |
151 | if( fcntl( nClient, F_SETFL, flags ) < 0) | 152 | if( fcntl( nClient, F_SETFL, flags ) < 0) |
152 | { | 153 | { |
153 | throw SocketException( | 154 | throw Bu::ServerSocketException( |
154 | "Error setting option on client socket: %s", | 155 | "Error setting option on client socket: %s", |
155 | strerror( errno ) | 156 | strerror( errno ) |
156 | ); | 157 | ); |