removed exception specifications. thread exceptions weren't
being listed and they'd have to be added to every one. just doesn't seem worth the trouble.
This commit is contained in:
parent
c6ed114410
commit
6aba3a6f57
|
@ -27,7 +27,7 @@ CBufferedInputStream::~CBufferedInputStream()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBufferedInputStream::write(
|
void CBufferedInputStream::write(
|
||||||
const void* data, UInt32 n) throw()
|
const void* data, UInt32 n)
|
||||||
{
|
{
|
||||||
if (!m_hungup && n > 0) {
|
if (!m_hungup && n > 0) {
|
||||||
m_buffer.write(data, n);
|
m_buffer.write(data, n);
|
||||||
|
@ -36,14 +36,14 @@ void CBufferedInputStream::write(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBufferedInputStream::hangup() throw()
|
void CBufferedInputStream::hangup()
|
||||||
{
|
{
|
||||||
m_hungup = true;
|
m_hungup = true;
|
||||||
m_empty.broadcast();
|
m_empty.broadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CBufferedInputStream::readNoLock(
|
UInt32 CBufferedInputStream::readNoLock(
|
||||||
void* dst, UInt32 n) throw(XIO)
|
void* dst, UInt32 n)
|
||||||
{
|
{
|
||||||
if (m_closed) {
|
if (m_closed) {
|
||||||
throw XIOClosed();
|
throw XIOClosed();
|
||||||
|
@ -74,12 +74,12 @@ UInt32 CBufferedInputStream::readNoLock(
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CBufferedInputStream::getSizeNoLock() const throw()
|
UInt32 CBufferedInputStream::getSizeNoLock() const
|
||||||
{
|
{
|
||||||
return m_buffer.getSize();
|
return m_buffer.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBufferedInputStream::close() throw(XIO)
|
void CBufferedInputStream::close()
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
if (m_closed) {
|
if (m_closed) {
|
||||||
|
@ -93,13 +93,13 @@ void CBufferedInputStream::close() throw(XIO)
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CBufferedInputStream::read(
|
UInt32 CBufferedInputStream::read(
|
||||||
void* dst, UInt32 n) throw(XIO)
|
void* dst, UInt32 n)
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
return readNoLock(dst, n);
|
return readNoLock(dst, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CBufferedInputStream::getSize() const throw()
|
UInt32 CBufferedInputStream::getSize() const
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
return getSizeNoLock();
|
return getSizeNoLock();
|
||||||
|
|
|
@ -19,25 +19,25 @@ class CBufferedInputStream : public IInputStream {
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// write() appends n bytes to the buffer
|
// write() appends n bytes to the buffer
|
||||||
void write(const void*, UInt32 n) throw();
|
void write(const void*, UInt32 n);
|
||||||
|
|
||||||
// causes read() to always return immediately. if there is no
|
// causes read() to always return immediately. if there is no
|
||||||
// more data then it returns 0. further writes are discarded.
|
// more data then it returns 0. further writes are discarded.
|
||||||
void hangup() throw();
|
void hangup();
|
||||||
|
|
||||||
// same as read() but caller must lock the mutex
|
// same as read() but caller must lock the mutex
|
||||||
UInt32 readNoLock(void*, UInt32 count) throw(XIO);
|
UInt32 readNoLock(void*, UInt32 count);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// same as getSize() but caller must lock the mutex
|
// same as getSize() but caller must lock the mutex
|
||||||
UInt32 getSizeNoLock() const throw();
|
UInt32 getSizeNoLock() const;
|
||||||
|
|
||||||
// IInputStream overrides
|
// IInputStream overrides
|
||||||
// these all lock the mutex for their duration
|
// these all lock the mutex for their duration
|
||||||
virtual void close() throw(XIO);
|
virtual void close();
|
||||||
virtual UInt32 read(void*, UInt32 count) throw(XIO);
|
virtual UInt32 read(void*, UInt32 count);
|
||||||
virtual UInt32 getSize() const throw();
|
virtual UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
|
|
|
@ -23,22 +23,22 @@ CBufferedOutputStream::~CBufferedOutputStream()
|
||||||
delete m_closeCB;
|
delete m_closeCB;
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* CBufferedOutputStream::peek(UInt32 n) throw()
|
const void* CBufferedOutputStream::peek(UInt32 n)
|
||||||
{
|
{
|
||||||
return m_buffer.peek(n);
|
return m_buffer.peek(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBufferedOutputStream::pop(UInt32 n) throw()
|
void CBufferedOutputStream::pop(UInt32 n)
|
||||||
{
|
{
|
||||||
m_buffer.pop(n);
|
m_buffer.pop(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CBufferedOutputStream::getSize() const throw()
|
UInt32 CBufferedOutputStream::getSize() const
|
||||||
{
|
{
|
||||||
return m_buffer.getSize();
|
return m_buffer.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBufferedOutputStream::close() throw(XIO)
|
void CBufferedOutputStream::close()
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
if (m_closed) {
|
if (m_closed) {
|
||||||
|
@ -52,7 +52,7 @@ void CBufferedOutputStream::close() throw(XIO)
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CBufferedOutputStream::write(
|
UInt32 CBufferedOutputStream::write(
|
||||||
const void* data, UInt32 n) throw(XIO)
|
const void* data, UInt32 n)
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
if (m_closed) {
|
if (m_closed) {
|
||||||
|
@ -63,7 +63,7 @@ UInt32 CBufferedOutputStream::write(
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBufferedOutputStream::flush() throw(XIO)
|
void CBufferedOutputStream::flush()
|
||||||
{
|
{
|
||||||
// wait until all data is written
|
// wait until all data is written
|
||||||
while (getSizeWithLock() > 0) {
|
while (getSizeWithLock() > 0) {
|
||||||
|
@ -71,7 +71,7 @@ void CBufferedOutputStream::flush() throw(XIO)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CBufferedOutputStream::getSizeWithLock() const throw()
|
UInt32 CBufferedOutputStream::getSizeWithLock() const
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
return m_buffer.getSize();
|
return m_buffer.getSize();
|
||||||
|
|
|
@ -19,22 +19,22 @@ class CBufferedOutputStream : public IOutputStream {
|
||||||
|
|
||||||
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
||||||
// pop() discards the next n bytes.
|
// pop() discards the next n bytes.
|
||||||
const void* peek(UInt32 n) throw();
|
const void* peek(UInt32 n);
|
||||||
void pop(UInt32 n) throw();
|
void pop(UInt32 n);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// return the number of bytes in the buffer
|
// return the number of bytes in the buffer
|
||||||
UInt32 getSize() const throw();
|
UInt32 getSize() const;
|
||||||
|
|
||||||
// IOutputStream overrides
|
// IOutputStream overrides
|
||||||
// these all lock the mutex for their duration
|
// these all lock the mutex for their duration
|
||||||
virtual void close() throw(XIO);
|
virtual void close();
|
||||||
virtual UInt32 write(const void*, UInt32 count) throw(XIO);
|
virtual UInt32 write(const void*, UInt32 count);
|
||||||
virtual void flush() throw(XIO);
|
virtual void flush();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 getSizeWithLock() const throw();
|
UInt32 getSizeWithLock() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
|
|
|
@ -19,7 +19,7 @@ CInputStreamFilter::~CInputStreamFilter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IInputStream* CInputStreamFilter::getStream() const throw()
|
IInputStream* CInputStreamFilter::getStream() const
|
||||||
{
|
{
|
||||||
return m_stream;
|
return m_stream;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ class CInputStreamFilter : public IInputStream {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// IInputStream overrides
|
// IInputStream overrides
|
||||||
virtual void close() throw(XIO) = 0;
|
virtual void close() = 0;
|
||||||
virtual UInt32 read(void*, UInt32 maxCount) throw(XIO) = 0;
|
virtual UInt32 read(void*, UInt32 maxCount) = 0;
|
||||||
virtual UInt32 getSize() const throw() = 0;
|
virtual UInt32 getSize() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IInputStream* getStream() const throw();
|
IInputStream* getStream() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IInputStream* m_stream;
|
IInputStream* m_stream;
|
||||||
|
|
|
@ -19,7 +19,7 @@ COutputStreamFilter::~COutputStreamFilter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IOutputStream* COutputStreamFilter::getStream() const throw()
|
IOutputStream* COutputStreamFilter::getStream() const
|
||||||
{
|
{
|
||||||
return m_stream;
|
return m_stream;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ class COutputStreamFilter : public IOutputStream {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// IOutputStream overrides
|
// IOutputStream overrides
|
||||||
virtual void close() throw(XIO) = 0;
|
virtual void close() = 0;
|
||||||
virtual UInt32 write(const void*, UInt32 count) throw(XIO) = 0;
|
virtual UInt32 write(const void*, UInt32 count) = 0;
|
||||||
virtual void flush() throw(XIO) = 0;
|
virtual void flush() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IOutputStream* getStream() const throw();
|
IOutputStream* getStream() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IOutputStream* m_stream;
|
IOutputStream* m_stream;
|
||||||
|
|
|
@ -17,7 +17,7 @@ CStreamBuffer::~CStreamBuffer()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* CStreamBuffer::peek(UInt32 n) throw()
|
const void* CStreamBuffer::peek(UInt32 n)
|
||||||
{
|
{
|
||||||
assert(n <= m_size);
|
assert(n <= m_size);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ const void* CStreamBuffer::peek(UInt32 n) throw()
|
||||||
return reinterpret_cast<const void*>(head->begin());
|
return reinterpret_cast<const void*>(head->begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStreamBuffer::pop(UInt32 n) throw()
|
void CStreamBuffer::pop(UInt32 n)
|
||||||
{
|
{
|
||||||
m_size -= n;
|
m_size -= n;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void CStreamBuffer::pop(UInt32 n) throw()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStreamBuffer::write(
|
void CStreamBuffer::write(
|
||||||
const void* vdata, UInt32 n) throw()
|
const void* vdata, UInt32 n)
|
||||||
{
|
{
|
||||||
assert(vdata != NULL);
|
assert(vdata != NULL);
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ void CStreamBuffer::write(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CStreamBuffer::getSize() const throw()
|
UInt32 CStreamBuffer::getSize() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,16 +14,16 @@ class CStreamBuffer {
|
||||||
|
|
||||||
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
||||||
// pop() discards the next n bytes.
|
// pop() discards the next n bytes.
|
||||||
const void* peek(UInt32 n) throw();
|
const void* peek(UInt32 n);
|
||||||
void pop(UInt32 n) throw();
|
void pop(UInt32 n);
|
||||||
|
|
||||||
// write() appends n bytes to the buffer
|
// write() appends n bytes to the buffer
|
||||||
void write(const void*, UInt32 n) throw();
|
void write(const void*, UInt32 n);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// return the number of bytes in the buffer
|
// return the number of bytes in the buffer
|
||||||
UInt32 getSize() const throw();
|
UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const UInt32 kChunkSize;
|
static const UInt32 kChunkSize;
|
||||||
|
|
|
@ -10,12 +10,12 @@ class IInputStream : public IInterface {
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// close the stream
|
// close the stream
|
||||||
virtual void close() throw(XIO) = 0;
|
virtual void close() = 0;
|
||||||
|
|
||||||
// read up to maxCount bytes into buffer, return number read.
|
// read up to maxCount bytes into buffer, return number read.
|
||||||
// blocks if no data is currently available. if buffer is NULL
|
// blocks if no data is currently available. if buffer is NULL
|
||||||
// then the data is discarded.
|
// then the data is discarded.
|
||||||
virtual UInt32 read(void* buffer, UInt32 maxCount) throw(XIO) = 0;
|
virtual UInt32 read(void* buffer, UInt32 maxCount) = 0;
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class IInputStream : public IInterface {
|
||||||
// (i.e. a number not greater than the actual number of bytes).
|
// (i.e. a number not greater than the actual number of bytes).
|
||||||
// some streams may not be able to determine this and will always
|
// some streams may not be able to determine this and will always
|
||||||
// return zero.
|
// return zero.
|
||||||
virtual UInt32 getSize() const throw() = 0;
|
virtual UInt32 getSize() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,13 +10,13 @@ class IOutputStream : public IInterface {
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// close the stream
|
// close the stream
|
||||||
virtual void close() throw(XIO) = 0;
|
virtual void close() = 0;
|
||||||
|
|
||||||
// write count bytes to stream
|
// write count bytes to stream
|
||||||
virtual UInt32 write(const void*, UInt32 count) throw(XIO) = 0;
|
virtual UInt32 write(const void*, UInt32 count) = 0;
|
||||||
|
|
||||||
// flush the stream
|
// flush the stream
|
||||||
virtual void flush() throw(XIO) = 0;
|
virtual void flush() = 0;
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,12 +21,12 @@ CCondVarBase::~CCondVarBase()
|
||||||
fini();
|
fini();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCondVarBase::lock() const throw()
|
void CCondVarBase::lock() const
|
||||||
{
|
{
|
||||||
m_mutex->lock();
|
m_mutex->lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCondVarBase::unlock() const throw()
|
void CCondVarBase::unlock() const
|
||||||
{
|
{
|
||||||
m_mutex->unlock();
|
m_mutex->unlock();
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ bool CCondVarBase::wait(double timeout) const
|
||||||
return wait(timer, timeout);
|
return wait(timer, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMutex* CCondVarBase::getMutex() const throw()
|
CMutex* CCondVarBase::getMutex() const
|
||||||
{
|
{
|
||||||
return m_mutex;
|
return m_mutex;
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,14 @@ void CCondVarBase::fini()
|
||||||
delete cond;
|
delete cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCondVarBase::signal() throw()
|
void CCondVarBase::signal()
|
||||||
{
|
{
|
||||||
pthread_cond_t* cond = reinterpret_cast<pthread_cond_t*>(m_cond);
|
pthread_cond_t* cond = reinterpret_cast<pthread_cond_t*>(m_cond);
|
||||||
int status = pthread_cond_signal(cond);
|
int status = pthread_cond_signal(cond);
|
||||||
assert(status == 0);
|
assert(status == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCondVarBase::broadcast() throw()
|
void CCondVarBase::broadcast()
|
||||||
{
|
{
|
||||||
pthread_cond_t* cond = reinterpret_cast<pthread_cond_t*>(m_cond);
|
pthread_cond_t* cond = reinterpret_cast<pthread_cond_t*>(m_cond);
|
||||||
int status = pthread_cond_broadcast(cond);
|
int status = pthread_cond_broadcast(cond);
|
||||||
|
@ -143,7 +143,7 @@ bool CCondVarBase::wait(
|
||||||
CThread::testCancel();
|
CThread::testCancel();
|
||||||
|
|
||||||
// check wait status
|
// check wait status
|
||||||
if (status != ETIMEDOUT)
|
if (status != ETIMEDOUT && status != EINTR)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ void CCondVarBase::fini()
|
||||||
delete[] events;
|
delete[] events;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCondVarBase::signal() throw()
|
void CCondVarBase::signal()
|
||||||
{
|
{
|
||||||
// is anybody waiting?
|
// is anybody waiting?
|
||||||
bool hasWaiter;
|
bool hasWaiter;
|
||||||
|
@ -213,7 +213,7 @@ void CCondVarBase::signal() throw()
|
||||||
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kSignal]);
|
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kSignal]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCondVarBase::broadcast() throw()
|
void CCondVarBase::broadcast()
|
||||||
{
|
{
|
||||||
// is anybody waiting?
|
// is anybody waiting?
|
||||||
bool hasWaiter;
|
bool hasWaiter;
|
||||||
|
|
|
@ -17,13 +17,13 @@ class CCondVarBase {
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// lock/unlock the mutex. see CMutex.
|
// lock/unlock the mutex. see CMutex.
|
||||||
void lock() const throw();
|
void lock() const;
|
||||||
void unlock() const throw();
|
void unlock() const;
|
||||||
|
|
||||||
// signal the condition. Signal() wakes one waiting thread.
|
// signal the condition. Signal() wakes one waiting thread.
|
||||||
// Broadcast() wakes all waiting threads.
|
// Broadcast() wakes all waiting threads.
|
||||||
void signal() throw();
|
void signal();
|
||||||
void broadcast() throw();
|
void broadcast();
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class CCondVarBase {
|
||||||
bool wait(CStopwatch&, double timeout) const;
|
bool wait(CStopwatch&, double timeout) const;
|
||||||
|
|
||||||
// get the mutex passed to the c'tor
|
// get the mutex passed to the c'tor
|
||||||
CMutex* getMutex() const throw();
|
CMutex* getMutex() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
@ -83,7 +83,7 @@ class CCondVar : public CCondVarBase {
|
||||||
|
|
||||||
// get the const value. this object should be locked before
|
// get the const value. this object should be locked before
|
||||||
// calling this method.
|
// calling this method.
|
||||||
operator const T&() const throw();
|
operator const T&() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_data;
|
T m_data;
|
||||||
|
@ -131,7 +131,7 @@ CCondVar<T>& CCondVar<T>::operator=(const T& data)
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline
|
inline
|
||||||
CCondVar<T>::operator const T&() const throw()
|
CCondVar<T>::operator const T&() const
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,17 @@
|
||||||
// CLock
|
// CLock
|
||||||
//
|
//
|
||||||
|
|
||||||
CLock::CLock(const CMutex* mutex) throw() : m_mutex(mutex)
|
CLock::CLock(const CMutex* mutex) : m_mutex(mutex)
|
||||||
{
|
{
|
||||||
m_mutex->lock();
|
m_mutex->lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
CLock::CLock(const CCondVarBase* cv) throw() : m_mutex(cv->getMutex())
|
CLock::CLock(const CCondVarBase* cv) : m_mutex(cv->getMutex())
|
||||||
{
|
{
|
||||||
m_mutex->lock();
|
m_mutex->lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
CLock::~CLock() throw()
|
CLock::~CLock()
|
||||||
{
|
{
|
||||||
m_mutex->unlock();
|
m_mutex->unlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@ class CCondVarBase;
|
||||||
|
|
||||||
class CLock {
|
class CLock {
|
||||||
public:
|
public:
|
||||||
CLock(const CMutex* mutex) throw();
|
CLock(const CMutex* mutex);
|
||||||
CLock(const CCondVarBase* cv) throw();
|
CLock(const CCondVarBase* cv);
|
||||||
~CLock() throw();
|
~CLock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// not implemented
|
// not implemented
|
||||||
|
|
|
@ -48,7 +48,7 @@ void CMutex::fini()
|
||||||
delete mutex;
|
delete mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMutex::lock() const throw()
|
void CMutex::lock() const
|
||||||
{
|
{
|
||||||
pthread_mutex_t* mutex = reinterpret_cast<pthread_mutex_t*>(m_mutex);
|
pthread_mutex_t* mutex = reinterpret_cast<pthread_mutex_t*>(m_mutex);
|
||||||
int status = pthread_mutex_lock(mutex);
|
int status = pthread_mutex_lock(mutex);
|
||||||
|
@ -71,7 +71,7 @@ void CMutex::lock() const throw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMutex::unlock() const throw()
|
void CMutex::unlock() const
|
||||||
{
|
{
|
||||||
pthread_mutex_t* mutex = reinterpret_cast<pthread_mutex_t*>(m_mutex);
|
pthread_mutex_t* mutex = reinterpret_cast<pthread_mutex_t*>(m_mutex);
|
||||||
int status = pthread_mutex_unlock(mutex);
|
int status = pthread_mutex_unlock(mutex);
|
||||||
|
@ -110,12 +110,12 @@ void CMutex::fini()
|
||||||
delete mutex;
|
delete mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMutex::lock() const throw()
|
void CMutex::lock() const
|
||||||
{
|
{
|
||||||
::EnterCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(m_mutex));
|
::EnterCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(m_mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMutex::unlock() const throw()
|
void CMutex::unlock() const
|
||||||
{
|
{
|
||||||
::LeaveCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(m_mutex));
|
::LeaveCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(m_mutex));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ class CMutex {
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
void lock() const throw();
|
void lock() const;
|
||||||
void unlock() const throw();
|
void unlock() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// CNetworkAddress
|
// CNetworkAddress
|
||||||
//
|
//
|
||||||
|
|
||||||
CNetworkAddress::CNetworkAddress(UInt16 port) throw(XSocketAddress)
|
CNetworkAddress::CNetworkAddress(UInt16 port)
|
||||||
{
|
{
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
throw XSocketAddress(XSocketAddress::kBadPort, CString(), port);
|
throw XSocketAddress(XSocketAddress::kBadPort, CString(), port);
|
||||||
|
@ -21,7 +21,6 @@ CNetworkAddress::CNetworkAddress(UInt16 port) throw(XSocketAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
CNetworkAddress::CNetworkAddress(const CString& hostname, UInt16 port)
|
CNetworkAddress::CNetworkAddress(const CString& hostname, UInt16 port)
|
||||||
throw(XSocketAddress)
|
|
||||||
{
|
{
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
throw XSocketAddress(XSocketAddress::kBadPort, hostname, port);
|
throw XSocketAddress(XSocketAddress::kBadPort, hostname, port);
|
||||||
|
@ -54,12 +53,12 @@ CNetworkAddress::~CNetworkAddress()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct sockaddr* CNetworkAddress::getAddress() const throw()
|
const struct sockaddr* CNetworkAddress::getAddress() const
|
||||||
{
|
{
|
||||||
return &m_address;
|
return &m_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CNetworkAddress::getAddressLength() const throw()
|
int CNetworkAddress::getAddressLength() const
|
||||||
{
|
{
|
||||||
return sizeof(m_address);
|
return sizeof(m_address);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,16 @@ class CString;
|
||||||
|
|
||||||
class CNetworkAddress {
|
class CNetworkAddress {
|
||||||
public:
|
public:
|
||||||
CNetworkAddress(UInt16 port) throw(XSocketAddress);
|
CNetworkAddress(UInt16 port);
|
||||||
CNetworkAddress(const CString& hostname, UInt16 port) throw(XSocketAddress);
|
CNetworkAddress(const CString& hostname, UInt16 port);
|
||||||
~CNetworkAddress();
|
~CNetworkAddress();
|
||||||
|
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
const struct sockaddr* getAddress() const throw();
|
const struct sockaddr* getAddress() const;
|
||||||
int getAddressLength() const throw();
|
int getAddressLength() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct sockaddr m_address;
|
struct sockaddr m_address;
|
||||||
|
|
|
@ -27,7 +27,7 @@ CSocketInputStream::~CSocketInputStream()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocketInputStream::write(
|
void CSocketInputStream::write(
|
||||||
const void* data, UInt32 n) throw()
|
const void* data, UInt32 n)
|
||||||
{
|
{
|
||||||
if (!m_hungup && n > 0) {
|
if (!m_hungup && n > 0) {
|
||||||
m_buffer.write(data, n);
|
m_buffer.write(data, n);
|
||||||
|
@ -36,13 +36,13 @@ void CSocketInputStream::write(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocketInputStream::hangup() throw()
|
void CSocketInputStream::hangup()
|
||||||
{
|
{
|
||||||
m_hungup = true;
|
m_hungup = true;
|
||||||
m_empty.broadcast();
|
m_empty.broadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocketInputStream::close() throw(XIO)
|
void CSocketInputStream::close()
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
if (m_closed) {
|
if (m_closed) {
|
||||||
|
@ -56,7 +56,7 @@ void CSocketInputStream::close() throw(XIO)
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CSocketInputStream::read(
|
UInt32 CSocketInputStream::read(
|
||||||
void* dst, UInt32 n) throw(XIO)
|
void* dst, UInt32 n)
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
if (m_closed) {
|
if (m_closed) {
|
||||||
|
@ -86,7 +86,7 @@ UInt32 CSocketInputStream::read(
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CSocketInputStream::getSize() const throw()
|
UInt32 CSocketInputStream::getSize() const
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
return m_buffer.getSize();
|
return m_buffer.getSize();
|
||||||
|
|
|
@ -16,19 +16,19 @@ class CSocketInputStream : public IInputStream {
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// write() appends n bytes to the buffer
|
// write() appends n bytes to the buffer
|
||||||
void write(const void*, UInt32 n) throw();
|
void write(const void*, UInt32 n);
|
||||||
|
|
||||||
// causes read() to always return immediately. if there is no
|
// causes read() to always return immediately. if there is no
|
||||||
// more data then it returns 0. further writes are discarded.
|
// more data then it returns 0. further writes are discarded.
|
||||||
void hangup() throw();
|
void hangup();
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// IInputStream overrides
|
// IInputStream overrides
|
||||||
// these all lock the mutex for their duration
|
// these all lock the mutex for their duration
|
||||||
virtual void close() throw(XIO);
|
virtual void close();
|
||||||
virtual UInt32 read(void*, UInt32 count) throw(XIO);
|
virtual UInt32 read(void*, UInt32 count);
|
||||||
virtual UInt32 getSize() const throw();
|
virtual UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
|
|
|
@ -23,22 +23,22 @@ CSocketOutputStream::~CSocketOutputStream()
|
||||||
delete m_closeCB;
|
delete m_closeCB;
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* CSocketOutputStream::peek(UInt32 n) throw()
|
const void* CSocketOutputStream::peek(UInt32 n)
|
||||||
{
|
{
|
||||||
return m_buffer.peek(n);
|
return m_buffer.peek(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocketOutputStream::pop(UInt32 n) throw()
|
void CSocketOutputStream::pop(UInt32 n)
|
||||||
{
|
{
|
||||||
m_buffer.pop(n);
|
m_buffer.pop(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CSocketOutputStream::getSize() const throw()
|
UInt32 CSocketOutputStream::getSize() const
|
||||||
{
|
{
|
||||||
return m_buffer.getSize();
|
return m_buffer.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocketOutputStream::close() throw(XIO)
|
void CSocketOutputStream::close()
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
if (m_closed) {
|
if (m_closed) {
|
||||||
|
@ -52,7 +52,7 @@ void CSocketOutputStream::close() throw(XIO)
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CSocketOutputStream::write(
|
UInt32 CSocketOutputStream::write(
|
||||||
const void* data, UInt32 n) throw(XIO)
|
const void* data, UInt32 n)
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
if (m_closed) {
|
if (m_closed) {
|
||||||
|
@ -63,7 +63,7 @@ UInt32 CSocketOutputStream::write(
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocketOutputStream::flush() throw(XIO)
|
void CSocketOutputStream::flush()
|
||||||
{
|
{
|
||||||
// wait until all data is written
|
// wait until all data is written
|
||||||
while (getSizeWithLock() > 0) {
|
while (getSizeWithLock() > 0) {
|
||||||
|
@ -71,7 +71,7 @@ void CSocketOutputStream::flush() throw(XIO)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CSocketOutputStream::getSizeWithLock() const throw()
|
UInt32 CSocketOutputStream::getSizeWithLock() const
|
||||||
{
|
{
|
||||||
CLock lock(m_mutex);
|
CLock lock(m_mutex);
|
||||||
return m_buffer.getSize();
|
return m_buffer.getSize();
|
||||||
|
|
|
@ -16,22 +16,22 @@ class CSocketOutputStream : public IOutputStream {
|
||||||
|
|
||||||
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
||||||
// pop() discards the next n bytes.
|
// pop() discards the next n bytes.
|
||||||
const void* peek(UInt32 n) throw();
|
const void* peek(UInt32 n);
|
||||||
void pop(UInt32 n) throw();
|
void pop(UInt32 n);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// return the number of bytes in the buffer
|
// return the number of bytes in the buffer
|
||||||
UInt32 getSize() const throw();
|
UInt32 getSize() const;
|
||||||
|
|
||||||
// IOutputStream overrides
|
// IOutputStream overrides
|
||||||
// these all lock the mutex for their duration
|
// these all lock the mutex for their duration
|
||||||
virtual void close() throw(XIO);
|
virtual void close();
|
||||||
virtual UInt32 write(const void*, UInt32 count) throw(XIO);
|
virtual UInt32 write(const void*, UInt32 count);
|
||||||
virtual void flush() throw(XIO);
|
virtual void flush();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 getSizeWithLock() const throw();
|
UInt32 getSizeWithLock() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
|
|
|
@ -17,7 +17,7 @@ CSocketStreamBuffer::~CSocketStreamBuffer()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* CSocketStreamBuffer::peek(UInt32 n) throw()
|
const void* CSocketStreamBuffer::peek(UInt32 n)
|
||||||
{
|
{
|
||||||
assert(n <= m_size);
|
assert(n <= m_size);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ const void* CSocketStreamBuffer::peek(UInt32 n) throw()
|
||||||
return reinterpret_cast<const void*>(head->begin());
|
return reinterpret_cast<const void*>(head->begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocketStreamBuffer::pop(UInt32 n) throw()
|
void CSocketStreamBuffer::pop(UInt32 n)
|
||||||
{
|
{
|
||||||
m_size -= n;
|
m_size -= n;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void CSocketStreamBuffer::pop(UInt32 n) throw()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocketStreamBuffer::write(
|
void CSocketStreamBuffer::write(
|
||||||
const void* vdata, UInt32 n) throw()
|
const void* vdata, UInt32 n)
|
||||||
{
|
{
|
||||||
assert(vdata != NULL);
|
assert(vdata != NULL);
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ void CSocketStreamBuffer::write(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CSocketStreamBuffer::getSize() const throw()
|
UInt32 CSocketStreamBuffer::getSize() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,16 +14,16 @@ class CSocketStreamBuffer {
|
||||||
|
|
||||||
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
||||||
// pop() discards the next n bytes.
|
// pop() discards the next n bytes.
|
||||||
const void* peek(UInt32 n) throw();
|
const void* peek(UInt32 n);
|
||||||
void pop(UInt32 n) throw();
|
void pop(UInt32 n);
|
||||||
|
|
||||||
// write() appends n bytes to the buffer
|
// write() appends n bytes to the buffer
|
||||||
void write(const void*, UInt32 n) throw();
|
void write(const void*, UInt32 n);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// return the number of bytes in the buffer
|
// return the number of bytes in the buffer
|
||||||
UInt32 getSize() const throw();
|
UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const UInt32 kChunkSize;
|
static const UInt32 kChunkSize;
|
||||||
|
|
|
@ -31,7 +31,7 @@ CTCPListenSocket::~CTCPListenSocket()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPListenSocket::bind(
|
void CTCPListenSocket::bind(
|
||||||
const CNetworkAddress& addr) throw(XSocket)
|
const CNetworkAddress& addr)
|
||||||
{
|
{
|
||||||
if (::bind(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
if (::bind(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
||||||
if (errno == EADDRINUSE) {
|
if (errno == EADDRINUSE) {
|
||||||
|
@ -44,7 +44,7 @@ void CTCPListenSocket::bind(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ISocket* CTCPListenSocket::accept() throw(XSocket)
|
ISocket* CTCPListenSocket::accept()
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
struct sockaddr addr;
|
struct sockaddr addr;
|
||||||
|
@ -60,7 +60,7 @@ ISocket* CTCPListenSocket::accept() throw(XSocket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPListenSocket::close() throw(XIO)
|
void CTCPListenSocket::close()
|
||||||
{
|
{
|
||||||
if (m_fd == -1) {
|
if (m_fd == -1) {
|
||||||
throw XIOClosed();
|
throw XIOClosed();
|
||||||
|
|
|
@ -13,9 +13,9 @@ class CTCPListenSocket : public IListenSocket {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// IListenSocket overrides
|
// IListenSocket overrides
|
||||||
virtual void bind(const CNetworkAddress&) throw(XSocket);
|
virtual void bind(const CNetworkAddress&);
|
||||||
virtual ISocket* accept() throw(XSocket);
|
virtual ISocket* accept();
|
||||||
virtual void close() throw(XIO);
|
virtual void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_fd;
|
int m_fd;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
// CTCPSocket
|
// CTCPSocket
|
||||||
//
|
//
|
||||||
|
|
||||||
CTCPSocket::CTCPSocket() throw(XSocket)
|
CTCPSocket::CTCPSocket()
|
||||||
{
|
{
|
||||||
m_fd = socket(PF_INET, SOCK_STREAM, 0);
|
m_fd = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
if (m_fd == -1) {
|
if (m_fd == -1) {
|
||||||
|
@ -29,7 +29,7 @@ CTCPSocket::CTCPSocket() throw(XSocket)
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CTCPSocket::CTCPSocket(int fd) throw() :
|
CTCPSocket::CTCPSocket(int fd) :
|
||||||
m_fd(fd)
|
m_fd(fd)
|
||||||
{
|
{
|
||||||
assert(m_fd != -1);
|
assert(m_fd != -1);
|
||||||
|
@ -60,7 +60,6 @@ CTCPSocket::~CTCPSocket()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPSocket::bind(const CNetworkAddress& addr)
|
void CTCPSocket::bind(const CNetworkAddress& addr)
|
||||||
throw(XSocket)
|
|
||||||
{
|
{
|
||||||
if (::bind(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
if (::bind(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
||||||
if (errno == EADDRINUSE) {
|
if (errno == EADDRINUSE) {
|
||||||
|
@ -71,7 +70,6 @@ void CTCPSocket::bind(const CNetworkAddress& addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPSocket::connect(const CNetworkAddress& addr)
|
void CTCPSocket::connect(const CNetworkAddress& addr)
|
||||||
throw(XSocket)
|
|
||||||
{
|
{
|
||||||
CThread::testCancel();
|
CThread::testCancel();
|
||||||
if (::connect(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
if (::connect(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
||||||
|
@ -85,7 +83,7 @@ void CTCPSocket::connect(const CNetworkAddress& addr)
|
||||||
this, &CTCPSocket::service));
|
this, &CTCPSocket::service));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPSocket::close() throw(XIO)
|
void CTCPSocket::close()
|
||||||
{
|
{
|
||||||
// shutdown I/O thread before close
|
// shutdown I/O thread before close
|
||||||
if (m_thread != NULL) {
|
if (m_thread != NULL) {
|
||||||
|
@ -114,17 +112,17 @@ void CTCPSocket::close() throw(XIO)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IInputStream* CTCPSocket::getInputStream() throw()
|
IInputStream* CTCPSocket::getInputStream()
|
||||||
{
|
{
|
||||||
return m_input;
|
return m_input;
|
||||||
}
|
}
|
||||||
|
|
||||||
IOutputStream* CTCPSocket::getOutputStream() throw()
|
IOutputStream* CTCPSocket::getOutputStream()
|
||||||
{
|
{
|
||||||
return m_output;
|
return m_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPSocket::init() throw(XIO)
|
void CTCPSocket::init()
|
||||||
{
|
{
|
||||||
m_mutex = new CMutex;
|
m_mutex = new CMutex;
|
||||||
m_thread = NULL;
|
m_thread = NULL;
|
||||||
|
@ -137,7 +135,7 @@ void CTCPSocket::init() throw(XIO)
|
||||||
this, &CTCPSocket::closeOutput));
|
this, &CTCPSocket::closeOutput));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPSocket::service(void*) throw(XThread)
|
void CTCPSocket::service(void*)
|
||||||
{
|
{
|
||||||
assert(m_fd != -1);
|
assert(m_fd != -1);
|
||||||
|
|
||||||
|
@ -211,14 +209,14 @@ void CTCPSocket::service(void*) throw(XThread)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPSocket::closeInput(void*) throw()
|
void CTCPSocket::closeInput(void*)
|
||||||
{
|
{
|
||||||
// note -- m_mutex should already be locked
|
// note -- m_mutex should already be locked
|
||||||
shutdown(m_fd, 0);
|
shutdown(m_fd, 0);
|
||||||
m_connected &= ~kRead;
|
m_connected &= ~kRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTCPSocket::closeOutput(void*) throw()
|
void CTCPSocket::closeOutput(void*)
|
||||||
{
|
{
|
||||||
// note -- m_mutex should already be locked
|
// note -- m_mutex should already be locked
|
||||||
shutdown(m_fd, 1);
|
shutdown(m_fd, 1);
|
||||||
|
|
|
@ -13,8 +13,8 @@ class CBufferedOutputStream;
|
||||||
|
|
||||||
class CTCPSocket : public ISocket {
|
class CTCPSocket : public ISocket {
|
||||||
public:
|
public:
|
||||||
CTCPSocket() throw(XSocket);
|
CTCPSocket();
|
||||||
CTCPSocket(int fd) throw();
|
CTCPSocket(int fd);
|
||||||
~CTCPSocket();
|
~CTCPSocket();
|
||||||
|
|
||||||
// manipulators
|
// manipulators
|
||||||
|
@ -22,17 +22,17 @@ class CTCPSocket : public ISocket {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// ISocket overrides
|
// ISocket overrides
|
||||||
virtual void bind(const CNetworkAddress&) throw(XSocket);
|
virtual void bind(const CNetworkAddress&);
|
||||||
virtual void connect(const CNetworkAddress&) throw(XSocket);
|
virtual void connect(const CNetworkAddress&);
|
||||||
virtual void close() throw(XIO);
|
virtual void close();
|
||||||
virtual IInputStream* getInputStream() throw();
|
virtual IInputStream* getInputStream();
|
||||||
virtual IOutputStream* getOutputStream() throw();
|
virtual IOutputStream* getOutputStream();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init() throw(XIO);
|
void init();
|
||||||
void service(void*) throw(XThread);
|
void service(void*);
|
||||||
void closeInput(void*) throw();
|
void closeInput(void*);
|
||||||
void closeOutput(void*) throw();
|
void closeOutput(void*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum { kClosed = 0, kRead = 1, kWrite = 2, kReadWrite = 3 };
|
enum { kClosed = 0, kRead = 1, kWrite = 2, kReadWrite = 3 };
|
||||||
|
|
|
@ -13,13 +13,13 @@ class IListenSocket : public IInterface {
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// bind the socket to a particular address
|
// bind the socket to a particular address
|
||||||
virtual void bind(const CNetworkAddress&) throw(XSocket) = 0;
|
virtual void bind(const CNetworkAddress&) = 0;
|
||||||
|
|
||||||
// wait for a connection
|
// wait for a connection
|
||||||
virtual ISocket* accept() throw(XSocket) = 0;
|
virtual ISocket* accept() = 0;
|
||||||
|
|
||||||
// close the socket
|
// close the socket
|
||||||
virtual void close() throw(XIO) = 0;
|
virtual void close() = 0;
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,19 +15,19 @@ class ISocket : public IInterface {
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// bind the socket to a particular address
|
// bind the socket to a particular address
|
||||||
virtual void bind(const CNetworkAddress&) throw(XSocket) = 0;
|
virtual void bind(const CNetworkAddress&) = 0;
|
||||||
|
|
||||||
// connect the socket
|
// connect the socket
|
||||||
virtual void connect(const CNetworkAddress&) throw(XSocket) = 0;
|
virtual void connect(const CNetworkAddress&) = 0;
|
||||||
|
|
||||||
// close the socket. this will flush the output stream if it
|
// close the socket. this will flush the output stream if it
|
||||||
// hasn't been closed yet.
|
// hasn't been closed yet.
|
||||||
virtual void close() throw(XIO) = 0;
|
virtual void close() = 0;
|
||||||
|
|
||||||
// get the input and output streams for the socket. closing
|
// get the input and output streams for the socket. closing
|
||||||
// these streams closes the appropriate half of the socket.
|
// these streams closes the appropriate half of the socket.
|
||||||
virtual IInputStream* getInputStream() throw() = 0;
|
virtual IInputStream* getInputStream() = 0;
|
||||||
virtual IOutputStream* getOutputStream() throw() = 0;
|
virtual IOutputStream* getOutputStream() = 0;
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,13 +20,13 @@ CInputPacketStream::~CInputPacketStream()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputPacketStream::close() throw(XIO)
|
void CInputPacketStream::close()
|
||||||
{
|
{
|
||||||
getStream()->close();
|
getStream()->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CInputPacketStream::read(
|
UInt32 CInputPacketStream::read(
|
||||||
void* buffer, UInt32 n) throw(XIO)
|
void* buffer, UInt32 n)
|
||||||
{
|
{
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
|
|
||||||
|
@ -50,13 +50,13 @@ UInt32 CInputPacketStream::read(
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CInputPacketStream::getSize() const throw()
|
UInt32 CInputPacketStream::getSize() const
|
||||||
{
|
{
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
return getSizeNoLock();
|
return getSizeNoLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CInputPacketStream::getSizeNoLock() const throw()
|
UInt32 CInputPacketStream::getSizeNoLock() const
|
||||||
{
|
{
|
||||||
while (!hasFullMessage()) {
|
while (!hasFullMessage()) {
|
||||||
// read more data
|
// read more data
|
||||||
|
@ -76,7 +76,7 @@ UInt32 CInputPacketStream::getSizeNoLock() const throw()
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputPacketStream::hasFullMessage() const throw()
|
bool CInputPacketStream::hasFullMessage() const
|
||||||
{
|
{
|
||||||
// get payload length if we don't have it yet
|
// get payload length if we don't have it yet
|
||||||
if (m_size == 0) {
|
if (m_size == 0) {
|
||||||
|
|
|
@ -15,13 +15,13 @@ class CInputPacketStream : public CInputStreamFilter {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// IInputStream overrides
|
// IInputStream overrides
|
||||||
virtual void close() throw(XIO);
|
virtual void close();
|
||||||
virtual UInt32 read(void*, UInt32 maxCount) throw(XIO);
|
virtual UInt32 read(void*, UInt32 maxCount);
|
||||||
virtual UInt32 getSize() const throw();
|
virtual UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 getSizeNoLock() const throw();
|
UInt32 getSizeNoLock() const;
|
||||||
bool hasFullMessage() const throw();
|
bool hasFullMessage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex m_mutex;
|
CMutex m_mutex;
|
||||||
|
|
|
@ -15,13 +15,13 @@ COutputPacketStream::~COutputPacketStream()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void COutputPacketStream::close() throw(XIO)
|
void COutputPacketStream::close()
|
||||||
{
|
{
|
||||||
getStream()->close();
|
getStream()->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 COutputPacketStream::write(
|
UInt32 COutputPacketStream::write(
|
||||||
const void* buffer, UInt32 count) throw(XIO)
|
const void* buffer, UInt32 count)
|
||||||
{
|
{
|
||||||
// write the length of the payload
|
// write the length of the payload
|
||||||
UInt8 length[4];
|
UInt8 length[4];
|
||||||
|
@ -49,7 +49,7 @@ UInt32 COutputPacketStream::write(
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void COutputPacketStream::flush() throw(XIO)
|
void COutputPacketStream::flush()
|
||||||
{
|
{
|
||||||
getStream()->flush();
|
getStream()->flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ class COutputPacketStream : public COutputStreamFilter {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// IOutputStream overrides
|
// IOutputStream overrides
|
||||||
virtual void close() throw(XIO);
|
virtual void close();
|
||||||
virtual UInt32 write(const void*, UInt32 count) throw(XIO);
|
virtual UInt32 write(const void*, UInt32 count);
|
||||||
virtual void flush() throw(XIO);
|
virtual void flush();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
void CProtocolUtil::writef(IOutputStream* stream,
|
void CProtocolUtil::writef(IOutputStream* stream,
|
||||||
const char* fmt, ...) throw(XIO)
|
const char* fmt, ...)
|
||||||
{
|
{
|
||||||
assert(stream != NULL);
|
assert(stream != NULL);
|
||||||
assert(fmt != NULL);
|
assert(fmt != NULL);
|
||||||
|
@ -48,7 +48,7 @@ void CProtocolUtil::writef(IOutputStream* stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
void CProtocolUtil::readf(IInputStream* stream,
|
void CProtocolUtil::readf(IInputStream* stream,
|
||||||
const char* fmt, ...) throw(XIO)
|
const char* fmt, ...)
|
||||||
{
|
{
|
||||||
assert(stream != NULL);
|
assert(stream != NULL);
|
||||||
assert(fmt != NULL);
|
assert(fmt != NULL);
|
||||||
|
@ -171,7 +171,7 @@ void CProtocolUtil::readf(IInputStream* stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CProtocolUtil::getLength(
|
UInt32 CProtocolUtil::getLength(
|
||||||
const char* fmt, va_list args) throw()
|
const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
UInt32 n = 0;
|
UInt32 n = 0;
|
||||||
while (*fmt) {
|
while (*fmt) {
|
||||||
|
@ -214,7 +214,7 @@ UInt32 CProtocolUtil::getLength(
|
||||||
}
|
}
|
||||||
|
|
||||||
void CProtocolUtil::writef(void* buffer,
|
void CProtocolUtil::writef(void* buffer,
|
||||||
const char* fmt, va_list args) throw(XIO)
|
const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
UInt8* dst = reinterpret_cast<UInt8*>(buffer);
|
UInt8* dst = reinterpret_cast<UInt8*>(buffer);
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ void CProtocolUtil::writef(void* buffer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 CProtocolUtil::eatLength(const char** pfmt) throw()
|
UInt32 CProtocolUtil::eatLength(const char** pfmt)
|
||||||
{
|
{
|
||||||
const char* fmt = *pfmt;
|
const char* fmt = *pfmt;
|
||||||
UInt32 n = 0;
|
UInt32 n = 0;
|
||||||
|
@ -310,7 +310,7 @@ UInt32 CProtocolUtil::eatLength(const char** pfmt) throw()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CProtocolUtil::read(IInputStream* stream,
|
void CProtocolUtil::read(IInputStream* stream,
|
||||||
void* vbuffer, UInt32 count) throw(XIO)
|
void* vbuffer, UInt32 count)
|
||||||
{
|
{
|
||||||
assert(stream != NULL);
|
assert(stream != NULL);
|
||||||
assert(vbuffer != NULL);
|
assert(vbuffer != NULL);
|
||||||
|
|
|
@ -22,7 +22,7 @@ class CProtocolUtil {
|
||||||
// %4i -- converts integer argument to 4 byte integer in NBO
|
// %4i -- converts integer argument to 4 byte integer in NBO
|
||||||
// %s -- converts integer N and const UInt8* to stream of N bytes
|
// %s -- converts integer N and const UInt8* to stream of N bytes
|
||||||
static void writef(IOutputStream*,
|
static void writef(IOutputStream*,
|
||||||
const char* fmt, ...) throw(XIO);
|
const char* fmt, ...);
|
||||||
|
|
||||||
// read formatted binary data from a buffer. this performs the
|
// read formatted binary data from a buffer. this performs the
|
||||||
// reverse operation of writef().
|
// reverse operation of writef().
|
||||||
|
@ -34,13 +34,13 @@ class CProtocolUtil {
|
||||||
// %4i -- reads an NBO 4 byte integer; arg is SInt32* or UInt32*
|
// %4i -- reads an NBO 4 byte integer; arg is SInt32* or UInt32*
|
||||||
// %s -- reads bytes; argument must be a CString*, *not* a char*
|
// %s -- reads bytes; argument must be a CString*, *not* a char*
|
||||||
static void readf(IInputStream*,
|
static void readf(IInputStream*,
|
||||||
const char* fmt, ...) throw(XIO);
|
const char* fmt, ...);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static UInt32 getLength(const char* fmt, va_list) throw();
|
static UInt32 getLength(const char* fmt, va_list);
|
||||||
static void writef(void*, const char* fmt, va_list) throw(XIO);
|
static void writef(void*, const char* fmt, va_list);
|
||||||
static UInt32 eatLength(const char** fmt) throw();
|
static UInt32 eatLength(const char** fmt);
|
||||||
static void read(IInputStream*, void*, UInt32) throw(XIO);
|
static void read(IInputStream*, void*, UInt32);
|
||||||
};
|
};
|
||||||
|
|
||||||
class XIOReadMismatch : public XIO {
|
class XIOReadMismatch : public XIO {
|
||||||
|
|
|
@ -76,7 +76,7 @@ void CScreenMap::disconnect(const CString& srcName,
|
||||||
}
|
}
|
||||||
|
|
||||||
CString CScreenMap::getNeighbor(const CString& srcName,
|
CString CScreenMap::getNeighbor(const CString& srcName,
|
||||||
EDirection srcSide) const throw()
|
EDirection srcSide) const
|
||||||
{
|
{
|
||||||
// find source cell
|
// find source cell
|
||||||
CCellMap::const_iterator index = m_map.find(srcName);
|
CCellMap::const_iterator index = m_map.find(srcName);
|
||||||
|
|
|
@ -31,7 +31,7 @@ class CScreenMap {
|
||||||
|
|
||||||
// get the neighbor in the given direction. returns the empty string
|
// get the neighbor in the given direction. returns the empty string
|
||||||
// if there is no neighbor in that direction.
|
// if there is no neighbor in that direction.
|
||||||
CString getNeighbor(const CString&, EDirection) const throw();
|
CString getNeighbor(const CString&, EDirection) const;
|
||||||
|
|
||||||
// get the name of a direction (for debugging)
|
// get the name of a direction (for debugging)
|
||||||
static const char* dirName(EDirection);
|
static const char* dirName(EDirection);
|
||||||
|
|
|
@ -96,7 +96,7 @@ void CServer::getScreenMap(CScreenMap* screenMap) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServer::setInfo(const CString& client,
|
void CServer::setInfo(const CString& client,
|
||||||
SInt32 w, SInt32 h, SInt32 zoneSize) throw()
|
SInt32 w, SInt32 h, SInt32 zoneSize)
|
||||||
{
|
{
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ void CServer::handshakeClient(void* vsocket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServer::quit() throw()
|
void CServer::quit()
|
||||||
{
|
{
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
m_done = true;
|
m_done = true;
|
||||||
|
@ -761,7 +761,7 @@ void CServer::openPrimaryScreen()
|
||||||
// FIXME -- need way for primary screen to call us back
|
// FIXME -- need way for primary screen to call us back
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServer::closePrimaryScreen() throw()
|
void CServer::closePrimaryScreen()
|
||||||
{
|
{
|
||||||
assert(m_primary != NULL);
|
assert(m_primary != NULL);
|
||||||
|
|
||||||
|
@ -802,7 +802,7 @@ void CServer::removeCleanupThread(const CThread& thread)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServer::cleanupThreads() throw()
|
void CServer::cleanupThreads()
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "cleaning up threads"));
|
log((CLOG_DEBUG "cleaning up threads"));
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
|
@ -839,7 +839,7 @@ void CServer::removeConnection(const CString& name)
|
||||||
log((CLOG_DEBUG "removing connection \"%s\"", name.c_str()));
|
log((CLOG_DEBUG "removing connection \"%s\"", name.c_str()));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
CScreenList::iterator index = m_screens.find(name);
|
CScreenList::iterator index = m_screens.find(name);
|
||||||
assert(index == m_screens.end());
|
assert(index != m_screens.end());
|
||||||
delete index->second;
|
delete index->second;
|
||||||
m_screens.erase(index);
|
m_screens.erase(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class CServer {
|
||||||
|
|
||||||
// handle messages from clients
|
// handle messages from clients
|
||||||
void setInfo(const CString& clientName,
|
void setInfo(const CString& clientName,
|
||||||
SInt32 w, SInt32 h, SInt32 zoneSize) throw();
|
SInt32 w, SInt32 h, SInt32 zoneSize);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class CServer {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onCommandKey(KeyID, KeyModifierMask, bool down);
|
bool onCommandKey(KeyID, KeyModifierMask, bool down);
|
||||||
void quit() throw();
|
void quit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class CCleanupNote {
|
class CCleanupNote {
|
||||||
|
@ -111,10 +111,10 @@ class CServer {
|
||||||
|
|
||||||
// open/close the primary screen
|
// open/close the primary screen
|
||||||
void openPrimaryScreen();
|
void openPrimaryScreen();
|
||||||
void closePrimaryScreen() throw();
|
void closePrimaryScreen();
|
||||||
|
|
||||||
// cancel running threads
|
// cancel running threads
|
||||||
void cleanupThreads() throw();
|
void cleanupThreads();
|
||||||
|
|
||||||
// thread method to accept incoming client connections
|
// thread method to accept incoming client connections
|
||||||
void acceptClients(void*);
|
void acceptClients(void*);
|
||||||
|
|
|
@ -26,22 +26,22 @@ CServerProtocol::~CServerProtocol()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
CServer* CServerProtocol::getServer() const throw()
|
CServer* CServerProtocol::getServer() const
|
||||||
{
|
{
|
||||||
return m_server;
|
return m_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString CServerProtocol::getClient() const throw()
|
CString CServerProtocol::getClient() const
|
||||||
{
|
{
|
||||||
return m_client;
|
return m_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
IInputStream* CServerProtocol::getInputStream() const throw()
|
IInputStream* CServerProtocol::getInputStream() const
|
||||||
{
|
{
|
||||||
return m_input;
|
return m_input;
|
||||||
}
|
}
|
||||||
|
|
||||||
IOutputStream* CServerProtocol::getOutputStream() const throw()
|
IOutputStream* CServerProtocol::getOutputStream() const
|
||||||
{
|
{
|
||||||
return m_output;
|
return m_output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,35 +18,35 @@ class CServerProtocol : public IServerProtocol {
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
virtual CServer* getServer() const throw();
|
virtual CServer* getServer() const;
|
||||||
virtual CString getClient() const throw();
|
virtual CString getClient() const;
|
||||||
virtual IInputStream* getInputStream() const throw();
|
virtual IInputStream* getInputStream() const;
|
||||||
virtual IOutputStream* getOutputStream() const throw();
|
virtual IOutputStream* getOutputStream() const;
|
||||||
|
|
||||||
static IServerProtocol* create(SInt32 major, SInt32 minor,
|
static IServerProtocol* create(SInt32 major, SInt32 minor,
|
||||||
CServer*, const CString& clientName,
|
CServer*, const CString& clientName,
|
||||||
IInputStream*, IOutputStream*);
|
IInputStream*, IOutputStream*);
|
||||||
|
|
||||||
// IServerProtocol overrides
|
// IServerProtocol overrides
|
||||||
virtual void run() throw(XIO,XBadClient) = 0;
|
virtual void run() = 0;
|
||||||
virtual void queryInfo() throw(XIO,XBadClient) = 0;
|
virtual void queryInfo() = 0;
|
||||||
virtual void sendClose() throw(XIO) = 0;
|
virtual void sendClose() = 0;
|
||||||
virtual void sendEnter(SInt32 xAbs, SInt32 yAbs) throw(XIO) = 0;
|
virtual void sendEnter(SInt32 xAbs, SInt32 yAbs) = 0;
|
||||||
virtual void sendLeave() throw(XIO) = 0;
|
virtual void sendLeave() = 0;
|
||||||
virtual void sendGrabClipboard() throw(XIO) = 0;
|
virtual void sendGrabClipboard() = 0;
|
||||||
virtual void sendQueryClipboard() throw(XIO) = 0;
|
virtual void sendQueryClipboard() = 0;
|
||||||
virtual void sendScreenSaver(bool on) throw(XIO) = 0;
|
virtual void sendScreenSaver(bool on) = 0;
|
||||||
virtual void sendKeyDown(KeyID, KeyModifierMask) throw(XIO) = 0;
|
virtual void sendKeyDown(KeyID, KeyModifierMask) = 0;
|
||||||
virtual void sendKeyRepeat(KeyID, KeyModifierMask) throw(XIO) = 0;
|
virtual void sendKeyRepeat(KeyID, KeyModifierMask) = 0;
|
||||||
virtual void sendKeyUp(KeyID, KeyModifierMask) throw(XIO) = 0;
|
virtual void sendKeyUp(KeyID, KeyModifierMask) = 0;
|
||||||
virtual void sendMouseDown(ButtonID) throw(XIO) = 0;
|
virtual void sendMouseDown(ButtonID) = 0;
|
||||||
virtual void sendMouseUp(ButtonID) throw(XIO) = 0;
|
virtual void sendMouseUp(ButtonID) = 0;
|
||||||
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs) throw(XIO) = 0;
|
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
|
||||||
virtual void sendMouseWheel(SInt32 delta) throw(XIO) = 0;
|
virtual void sendMouseWheel(SInt32 delta) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//IServerProtocol overrides
|
//IServerProtocol overrides
|
||||||
virtual void recvInfo() throw(XIO,XBadClient) = 0;
|
virtual void recvInfo() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CServer* m_server;
|
CServer* m_server;
|
||||||
|
|
|
@ -22,7 +22,7 @@ CServerProtocol1_0::~CServerProtocol1_0()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::run() throw(XIO,XBadClient)
|
void CServerProtocol1_0::run()
|
||||||
{
|
{
|
||||||
// handle messages until the client hangs up
|
// handle messages until the client hangs up
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -53,7 +53,7 @@ void CServerProtocol1_0::run() throw(XIO,XBadClient)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::queryInfo() throw(XIO,XBadClient)
|
void CServerProtocol1_0::queryInfo()
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "querying client \"%s\" info", getClient().c_str()));
|
log((CLOG_INFO "querying client \"%s\" info", getClient().c_str()));
|
||||||
|
|
||||||
|
@ -71,93 +71,93 @@ void CServerProtocol1_0::queryInfo() throw(XIO,XBadClient)
|
||||||
recvInfo();
|
recvInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendClose() throw(XIO)
|
void CServerProtocol1_0::sendClose()
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send close to \"%s\"", getClient().c_str()));
|
log((CLOG_INFO "send close to \"%s\"", getClient().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCClose);
|
CProtocolUtil::writef(getOutputStream(), kMsgCClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendEnter(
|
void CServerProtocol1_0::sendEnter(
|
||||||
SInt32 xAbs, SInt32 yAbs) throw(XIO)
|
SInt32 xAbs, SInt32 yAbs)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send enter to \"%s\", %d,%d", getClient().c_str(), xAbs, yAbs));
|
log((CLOG_INFO "send enter to \"%s\", %d,%d", getClient().c_str(), xAbs, yAbs));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCEnter, xAbs, yAbs);
|
CProtocolUtil::writef(getOutputStream(), kMsgCEnter, xAbs, yAbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendLeave() throw(XIO)
|
void CServerProtocol1_0::sendLeave()
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send leave to \"%s\"", getClient().c_str()));
|
log((CLOG_INFO "send leave to \"%s\"", getClient().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCLeave);
|
CProtocolUtil::writef(getOutputStream(), kMsgCLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendGrabClipboard() throw(XIO)
|
void CServerProtocol1_0::sendGrabClipboard()
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send grab clipboard to \"%s\"", getClient().c_str()));
|
log((CLOG_INFO "send grab clipboard to \"%s\"", getClient().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard);
|
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendQueryClipboard() throw(XIO)
|
void CServerProtocol1_0::sendQueryClipboard()
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "query clipboard to \"%s\"", getClient().c_str()));
|
log((CLOG_INFO "query clipboard to \"%s\"", getClient().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgQClipboard);
|
CProtocolUtil::writef(getOutputStream(), kMsgQClipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendScreenSaver(bool on) throw(XIO)
|
void CServerProtocol1_0::sendScreenSaver(bool on)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send screen saver to \"%s\"", getClient().c_str()));
|
log((CLOG_INFO "send screen saver to \"%s\"", getClient().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCScreenSaver, on ? 1 : 0);
|
CProtocolUtil::writef(getOutputStream(), kMsgCScreenSaver, on ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendKeyDown(
|
void CServerProtocol1_0::sendKeyDown(
|
||||||
KeyID key, KeyModifierMask mask) throw(XIO)
|
KeyID key, KeyModifierMask mask)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send key down to \"%s\" id=%d, mask=0x%04x", getClient().c_str(), key, mask));
|
log((CLOG_INFO "send key down to \"%s\" id=%d, mask=0x%04x", getClient().c_str(), key, mask));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDKeyDown, key, mask);
|
CProtocolUtil::writef(getOutputStream(), kMsgDKeyDown, key, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendKeyRepeat(
|
void CServerProtocol1_0::sendKeyRepeat(
|
||||||
KeyID key, KeyModifierMask mask) throw(XIO)
|
KeyID key, KeyModifierMask mask)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send key repeat to \"%s\" id=%d, mask=0x%04x", getClient().c_str(), key, mask));
|
log((CLOG_INFO "send key repeat to \"%s\" id=%d, mask=0x%04x", getClient().c_str(), key, mask));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDKeyRepeat, key, mask);
|
CProtocolUtil::writef(getOutputStream(), kMsgDKeyRepeat, key, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendKeyUp(
|
void CServerProtocol1_0::sendKeyUp(
|
||||||
KeyID key, KeyModifierMask mask) throw(XIO)
|
KeyID key, KeyModifierMask mask)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send key up to \"%s\" id=%d, mask=0x%04x", getClient().c_str(), key, mask));
|
log((CLOG_INFO "send key up to \"%s\" id=%d, mask=0x%04x", getClient().c_str(), key, mask));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDKeyUp, key, mask);
|
CProtocolUtil::writef(getOutputStream(), kMsgDKeyUp, key, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendMouseDown(
|
void CServerProtocol1_0::sendMouseDown(
|
||||||
ButtonID button) throw(XIO)
|
ButtonID button)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send mouse down to \"%s\" id=%d", getClient().c_str(), button));
|
log((CLOG_INFO "send mouse down to \"%s\" id=%d", getClient().c_str(), button));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDMouseDown, button);
|
CProtocolUtil::writef(getOutputStream(), kMsgDMouseDown, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendMouseUp(
|
void CServerProtocol1_0::sendMouseUp(
|
||||||
ButtonID button) throw(XIO)
|
ButtonID button)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send mouse up to \"%s\" id=%d", getClient().c_str(), button));
|
log((CLOG_INFO "send mouse up to \"%s\" id=%d", getClient().c_str(), button));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDMouseUp, button);
|
CProtocolUtil::writef(getOutputStream(), kMsgDMouseUp, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendMouseMove(
|
void CServerProtocol1_0::sendMouseMove(
|
||||||
SInt32 xAbs, SInt32 yAbs) throw(XIO)
|
SInt32 xAbs, SInt32 yAbs)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send mouse move to \"%s\" %d,%d", getClient().c_str(), xAbs, yAbs));
|
log((CLOG_INFO "send mouse move to \"%s\" %d,%d", getClient().c_str(), xAbs, yAbs));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDMouseMove, xAbs, yAbs);
|
CProtocolUtil::writef(getOutputStream(), kMsgDMouseMove, xAbs, yAbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::sendMouseWheel(
|
void CServerProtocol1_0::sendMouseWheel(
|
||||||
SInt32 delta) throw(XIO)
|
SInt32 delta)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "send mouse wheel to \"%s\" %+d", getClient().c_str(), delta));
|
log((CLOG_INFO "send mouse wheel to \"%s\" %+d", getClient().c_str(), delta));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDMouseWheel, delta);
|
CProtocolUtil::writef(getOutputStream(), kMsgDMouseWheel, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerProtocol1_0::recvInfo() throw(XIO,XBadClient)
|
void CServerProtocol1_0::recvInfo()
|
||||||
{
|
{
|
||||||
// parse the message
|
// parse the message
|
||||||
SInt32 w, h, zoneInfo;
|
SInt32 w, h, zoneInfo;
|
||||||
|
|
|
@ -13,25 +13,25 @@ class CServerProtocol1_0 : public CServerProtocol {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// IServerProtocol overrides
|
// IServerProtocol overrides
|
||||||
virtual void run() throw(XIO,XBadClient);
|
virtual void run();
|
||||||
virtual void queryInfo() throw(XIO,XBadClient);
|
virtual void queryInfo();
|
||||||
virtual void sendClose() throw(XIO);
|
virtual void sendClose();
|
||||||
virtual void sendEnter(SInt32 xAbs, SInt32 yAbs) throw(XIO);
|
virtual void sendEnter(SInt32 xAbs, SInt32 yAbs);
|
||||||
virtual void sendLeave() throw(XIO);
|
virtual void sendLeave();
|
||||||
virtual void sendGrabClipboard() throw(XIO);
|
virtual void sendGrabClipboard();
|
||||||
virtual void sendQueryClipboard() throw(XIO);
|
virtual void sendQueryClipboard();
|
||||||
virtual void sendScreenSaver(bool on) throw(XIO);
|
virtual void sendScreenSaver(bool on);
|
||||||
virtual void sendKeyDown(KeyID, KeyModifierMask) throw(XIO);
|
virtual void sendKeyDown(KeyID, KeyModifierMask);
|
||||||
virtual void sendKeyRepeat(KeyID, KeyModifierMask) throw(XIO);
|
virtual void sendKeyRepeat(KeyID, KeyModifierMask);
|
||||||
virtual void sendKeyUp(KeyID, KeyModifierMask) throw(XIO);
|
virtual void sendKeyUp(KeyID, KeyModifierMask);
|
||||||
virtual void sendMouseDown(ButtonID) throw(XIO);
|
virtual void sendMouseDown(ButtonID);
|
||||||
virtual void sendMouseUp(ButtonID) throw(XIO);
|
virtual void sendMouseUp(ButtonID);
|
||||||
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs) throw(XIO);
|
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs);
|
||||||
virtual void sendMouseWheel(SInt32 delta) throw(XIO);
|
virtual void sendMouseWheel(SInt32 delta);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// IServerProtocol overrides
|
// IServerProtocol overrides
|
||||||
virtual void recvInfo() throw(XIO,XBadClient);
|
virtual void recvInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,12 +16,12 @@ CTCPSocketFactory::~CTCPSocketFactory()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
ISocket* CTCPSocketFactory::create() const throw(XSocket)
|
ISocket* CTCPSocketFactory::create() const
|
||||||
{
|
{
|
||||||
return new CTCPSocket;
|
return new CTCPSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
IListenSocket* CTCPSocketFactory::createListen() const throw(XSocket)
|
IListenSocket* CTCPSocketFactory::createListen() const
|
||||||
{
|
{
|
||||||
return new CTCPListenSocket;
|
return new CTCPListenSocket;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ class CTCPSocketFactory : public ISocketFactory {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// ISocketFactory overrides
|
// ISocketFactory overrides
|
||||||
virtual ISocket* create() const throw(XSocket);
|
virtual ISocket* create() const;
|
||||||
virtual IListenSocket* createListen() const throw(XSocket);
|
virtual IListenSocket* createListen() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,32 +14,32 @@ class IServerProtocol : public IInterface {
|
||||||
// process messages from the client and insert the appropriate
|
// process messages from the client and insert the appropriate
|
||||||
// events into the server's event queue. return when the client
|
// events into the server's event queue. return when the client
|
||||||
// disconnects.
|
// disconnects.
|
||||||
virtual void run() throw(XIO,XBadClient) = 0;
|
virtual void run() = 0;
|
||||||
|
|
||||||
// send client info query and process reply
|
// send client info query and process reply
|
||||||
virtual void queryInfo() throw(XIO,XBadClient) = 0;
|
virtual void queryInfo() = 0;
|
||||||
|
|
||||||
// send various messages to client
|
// send various messages to client
|
||||||
virtual void sendClose() throw(XIO) = 0;
|
virtual void sendClose() = 0;
|
||||||
virtual void sendEnter(SInt32 xAbs, SInt32 yAbs) throw(XIO) = 0;
|
virtual void sendEnter(SInt32 xAbs, SInt32 yAbs) = 0;
|
||||||
virtual void sendLeave() throw(XIO) = 0;
|
virtual void sendLeave() = 0;
|
||||||
virtual void sendGrabClipboard() throw(XIO) = 0;
|
virtual void sendGrabClipboard() = 0;
|
||||||
virtual void sendQueryClipboard() throw(XIO) = 0;
|
virtual void sendQueryClipboard() = 0;
|
||||||
virtual void sendScreenSaver(bool on) throw(XIO) = 0;
|
virtual void sendScreenSaver(bool on) = 0;
|
||||||
virtual void sendKeyDown(KeyID, KeyModifierMask) throw(XIO) = 0;
|
virtual void sendKeyDown(KeyID, KeyModifierMask) = 0;
|
||||||
virtual void sendKeyRepeat(KeyID, KeyModifierMask) throw(XIO) = 0;
|
virtual void sendKeyRepeat(KeyID, KeyModifierMask) = 0;
|
||||||
virtual void sendKeyUp(KeyID, KeyModifierMask) throw(XIO) = 0;
|
virtual void sendKeyUp(KeyID, KeyModifierMask) = 0;
|
||||||
virtual void sendMouseDown(ButtonID) throw(XIO) = 0;
|
virtual void sendMouseDown(ButtonID) = 0;
|
||||||
virtual void sendMouseUp(ButtonID) throw(XIO) = 0;
|
virtual void sendMouseUp(ButtonID) = 0;
|
||||||
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs) throw(XIO) = 0;
|
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
|
||||||
virtual void sendMouseWheel(SInt32 delta) throw(XIO) = 0;
|
virtual void sendMouseWheel(SInt32 delta) = 0;
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
virtual void recvInfo() throw(XIO,XBadClient) = 0;
|
virtual void recvInfo() = 0;
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,8 +14,8 @@ class ISocketFactory : public IInterface {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// create sockets
|
// create sockets
|
||||||
virtual ISocket* create() const throw(XSocket) = 0;
|
virtual ISocket* create() const = 0;
|
||||||
virtual IListenSocket* createListen() const throw(XSocket) = 0;
|
virtual IListenSocket* createListen() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue