diff options
Diffstat (limited to 'lib/common/IOStream.cpp')
-rw-r--r-- | lib/common/IOStream.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/common/IOStream.cpp b/lib/common/IOStream.cpp index 3c7be561..76fb7fed 100644 --- a/lib/common/IOStream.cpp +++ b/lib/common/IOStream.cpp @@ -238,4 +238,24 @@ bool IOStream::CopyStreamTo(IOStream &rCopyTo, int Timeout, int BufferSize) return true; // completed } +// -------------------------------------------------------------------------- +// +// Function +// Name: IOStream::Flush(int Timeout) +// Purpose: Read and discard all remaining data in stream. +// Useful for protocol streams which must be flushed +// to avoid breaking the protocol. +// Created: 2008/08/20 +// +// -------------------------------------------------------------------------- +void IOStream::Flush(int Timeout) +{ + char buffer[4096]; + + while(StreamDataLeft()) + { + Read(buffer, sizeof(buffer), Timeout); + } +} + |