From 8b12972092777af56ae21f65b41f4c40d52c2367 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 18 Jun 2007 19:42:34 +0000 Subject: Added the protocol class. servers work, but don't send data, updated the streams to include many more state indicators and caps queries, and everything is working better in general. --- src/socket.cpp | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'src/socket.cpp') 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() ::close( nSocket ); } bActive = false; - //xInputBuf.clearData(); - //xOutputBuf.clearData(); - //if( pProtocol != NULL ) - //{ - // delete pProtocol; - // pProtocol = NULL; - //} } /* @@ -218,15 +211,49 @@ bool Bu::Socket::isEOS() bool Bu::Socket::canRead() { + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(nSocket, &rfds); + struct timeval tv = { 0, 0 }; + int retval = select( nSocket+1, &rfds, NULL, NULL, &tv ); + if( retval == -1 ) + throw ConnectionException( + excodeBadReadError, + "Bad Read error" + ); + if( !FD_ISSET( nSocket, &rfds ) ) + return false; return true; } bool Bu::Socket::canWrite() { + fd_set wfds; + FD_ZERO(&wfds); + FD_SET(nSocket, &wfds); + struct timeval tv = { 0, 0 }; + int retval = select( nSocket+1, NULL, &wfds, NULL, &tv ); + if( retval == -1 ) + throw ConnectionException( + excodeBadReadError, + "Bad Read error" + ); + if( !FD_ISSET( nSocket, &wfds ) ) + return false; return true; } -bool Bu::Socket::canSeek() +bool Bu::Socket::isReadable() +{ + return true; +} + +bool Bu::Socket::isWritable() +{ + return true; +} + +bool Bu::Socket::isSeekable() { return false; } @@ -244,3 +271,8 @@ void Bu::Socket::flush() { } +bool Bu::Socket::isOpen() +{ + return bActive; +} + -- cgit v1.2.3