aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-06-21 22:50:21 +0000
committerMike Buland <eichlan@xagasoft.com>2006-06-21 22:50:21 +0000
commit0acdeb045f1bf6caae786c474d99cea68071f31f (patch)
tree280691a5ecd6d488822f73a90a4f26b5da7fe682 /src
parent5f029cf734e1c84b7dcde8383bbc85aada08ee1c (diff)
downloadlibbu++-0acdeb045f1bf6caae786c474d99cea68071f31f.tar.gz
libbu++-0acdeb045f1bf6caae786c474d99cea68071f31f.tar.bz2
libbu++-0acdeb045f1bf6caae786c474d99cea68071f31f.tar.xz
libbu++-0acdeb045f1bf6caae786c474d99cea68071f31f.zip
Updated the readInput function to tell you how much time is left over after
blocking.
Diffstat (limited to '')
-rw-r--r--src/connection.cpp6
-rw-r--r--src/connection.h9
2 files changed, 11 insertions, 4 deletions
diff --git a/src/connection.cpp b/src/connection.cpp
index a277ea7..5b79dfe 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -238,7 +238,7 @@ bool Connection::readInput()
238 return true; 238 return true;
239} 239}
240 240
241bool Connection::readInput( int nSec, int nUSec ) 241bool Connection::readInput( int nSec, int nUSec, int *pnSecBack, int *pnUSecBack )
242{ 242{
243 fd_set rfds; 243 fd_set rfds;
244 struct timeval tv; 244 struct timeval tv;
@@ -252,7 +252,9 @@ bool Connection::readInput( int nSec, int nUSec )
252 tv.tv_usec = nUSec; 252 tv.tv_usec = nUSec;
253 253
254 retval = select( nSocket+1, &rfds, NULL, NULL, &tv ); 254 retval = select( nSocket+1, &rfds, NULL, NULL, &tv );
255 /* Don't rely on the value of tv now! */ 255
256 if( pnSecBack ) (*pnSecBack) = tv.tv_sec;
257 if( pnUSecBack ) (*pnUSecBack) = tv.tv_usec;
256 258
257 if (retval == -1) 259 if (retval == -1)
258 { 260 {
diff --git a/src/connection.h b/src/connection.h
index efb8630..dd4112b 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -272,11 +272,16 @@ public:
272 * Reads all pending input from the connection, blocking up to nSec 272 * Reads all pending input from the connection, blocking up to nSec
273 * seconds and nUSec micro-seconds for the data. This uses select to 273 * seconds and nUSec micro-seconds for the data. This uses select to
274 * simulate blocking, but has the same effect as standard io blocking. 274 * simulate blocking, but has the same effect as standard io blocking.
275 * If you don't want to block, just set both values to zero. 275 * If you don't want to block, just set both values to zero. The back
276 * parameters are optional, set to null to not use them. The variables
277 * you pass in through the back parameters will contain the remaining
278 * time if data arrived before the max timeout was reached.
276 *@param nSec Max seconds to wait. 279 *@param nSec Max seconds to wait.
277 *@param nUSec Max micro-seconds to wait. 280 *@param nUSec Max micro-seconds to wait.
281 *@param pnSecBack The number of seconds remaining.
282 *@param pnUSecBack The number of micro-seconds remaining.
278 */ 283 */
279 bool readInput( int nSec, int nUSec ); 284 bool readInput( int nSec, int nUSec, int *pnSecBack=NULL, int *pnUSecBack=NULL );
280 285
281 /** Writes all data that is pending to the socket. 286 /** Writes all data that is pending to the socket.
282 *@returns True if all data was written succesfully, false otherwise. 287 *@returns True if all data was written succesfully, false otherwise.