diff options
Diffstat (limited to 'src/socket.cpp')
-rw-r--r-- | src/socket.cpp | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/src/socket.cpp b/src/socket.cpp index 1832898..bd05024 100644 --- a/src/socket.cpp +++ b/src/socket.cpp | |||
@@ -109,13 +109,6 @@ void Bu::Socket::close() | |||
109 | ::close( nSocket ); | 109 | ::close( nSocket ); |
110 | } | 110 | } |
111 | bActive = false; | 111 | bActive = false; |
112 | //xInputBuf.clearData(); | ||
113 | //xOutputBuf.clearData(); | ||
114 | //if( pProtocol != NULL ) | ||
115 | //{ | ||
116 | // delete pProtocol; | ||
117 | // pProtocol = NULL; | ||
118 | //} | ||
119 | } | 112 | } |
120 | 113 | ||
121 | /* | 114 | /* |
@@ -218,15 +211,49 @@ bool Bu::Socket::isEOS() | |||
218 | 211 | ||
219 | bool Bu::Socket::canRead() | 212 | bool Bu::Socket::canRead() |
220 | { | 213 | { |
214 | fd_set rfds; | ||
215 | FD_ZERO(&rfds); | ||
216 | FD_SET(nSocket, &rfds); | ||
217 | struct timeval tv = { 0, 0 }; | ||
218 | int retval = select( nSocket+1, &rfds, NULL, NULL, &tv ); | ||
219 | if( retval == -1 ) | ||
220 | throw ConnectionException( | ||
221 | excodeBadReadError, | ||
222 | "Bad Read error" | ||
223 | ); | ||
224 | if( !FD_ISSET( nSocket, &rfds ) ) | ||
225 | return false; | ||
221 | return true; | 226 | return true; |
222 | } | 227 | } |
223 | 228 | ||
224 | bool Bu::Socket::canWrite() | 229 | bool Bu::Socket::canWrite() |
225 | { | 230 | { |
231 | fd_set wfds; | ||
232 | FD_ZERO(&wfds); | ||
233 | FD_SET(nSocket, &wfds); | ||
234 | struct timeval tv = { 0, 0 }; | ||
235 | int retval = select( nSocket+1, NULL, &wfds, NULL, &tv ); | ||
236 | if( retval == -1 ) | ||
237 | throw ConnectionException( | ||
238 | excodeBadReadError, | ||
239 | "Bad Read error" | ||
240 | ); | ||
241 | if( !FD_ISSET( nSocket, &wfds ) ) | ||
242 | return false; | ||
226 | return true; | 243 | return true; |
227 | } | 244 | } |
228 | 245 | ||
229 | bool Bu::Socket::canSeek() | 246 | bool Bu::Socket::isReadable() |
247 | { | ||
248 | return true; | ||
249 | } | ||
250 | |||
251 | bool Bu::Socket::isWritable() | ||
252 | { | ||
253 | return true; | ||
254 | } | ||
255 | |||
256 | bool Bu::Socket::isSeekable() | ||
230 | { | 257 | { |
231 | return false; | 258 | return false; |
232 | } | 259 | } |
@@ -244,3 +271,8 @@ void Bu::Socket::flush() | |||
244 | { | 271 | { |
245 | } | 272 | } |
246 | 273 | ||
274 | bool Bu::Socket::isOpen() | ||
275 | { | ||
276 | return bActive; | ||
277 | } | ||
278 | |||