/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright 2011 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <rdr/FdOutStream.h>
#include <rdr/Exception.h>
+#include <rfb/util.h>
using namespace rdr;
{
ptr = start = sentUpTo = new U8[bufSize];
end = start + bufSize;
+
+ gettimeofday(&lastWrite, NULL);
}
FdOutStream::~FdOutStream()
return ptr - sentUpTo;
}
+unsigned FdOutStream::getIdleTime()
+{
+ return rfb::msSince(&lastWrite);
+}
+
void FdOutStream::flush()
{
int timeoutms_;
if (n < 0) throw SystemException("write",errno);
+ gettimeofday(&lastWrite, NULL);
+
return n;
}
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright 2011 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#ifndef __RDR_FDOUTSTREAM_H__
#define __RDR_FDOUTSTREAM_H__
+#include <sys/time.h>
+
#include <rdr/OutStream.h>
namespace rdr {
int bufferUsage();
+ unsigned getIdleTime();
+
private:
int overrun(int itemSize, int nItems);
int writeWithTimeout(const void* data, int length, int timeoutms);
int offset;
U8* start;
U8* sentUpTo;
+ struct timeval lastWrite;
};
}