summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-06-29 00:48:32 +0000
committerMike Buland <eichlan@xagasoft.com>2007-06-29 00:48:32 +0000
commitec8ed8b4b44c7b039e87faaa50bb4d503393d336 (patch)
tree7ea933f72bf2186f12658f96a30e451622fc485a /src/client.cpp
parent76ea96f91115585f7c6b49d11ba60ec15bee12e6 (diff)
downloadlibbu++-ec8ed8b4b44c7b039e87faaa50bb4d503393d336.tar.gz
libbu++-ec8ed8b4b44c7b039e87faaa50bb4d503393d336.tar.bz2
libbu++-ec8ed8b4b44c7b039e87faaa50bb4d503393d336.tar.xz
libbu++-ec8ed8b4b44c7b039e87faaa50bb4d503393d336.zip
A few changes here and there, mainly related to getting the new Server system
working in optimal condition...
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 2f293b7..8077b3d 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -99,9 +99,9 @@ bool Bu::Client::isOpen()
99 return pSocket->isOpen(); 99 return pSocket->isOpen();
100} 100}
101 101
102void Bu::Client::write( const char *pData, int nBytes ) 102void Bu::Client::write( const void *pData, int nBytes )
103{ 103{
104 sWriteBuf.append( pData, nBytes ); 104 sWriteBuf.append( (const char *)pData, nBytes );
105} 105}
106 106
107void Bu::Client::write( int8_t nData ) 107void Bu::Client::write( int8_t nData )
@@ -144,7 +144,7 @@ void Bu::Client::write( uint64_t nData )
144 sWriteBuf.append( (const char *)&nData, sizeof(nData) ); 144 sWriteBuf.append( (const char *)&nData, sizeof(nData) );
145} 145}
146 146
147void Bu::Client::read( char *pData, int nBytes ) 147void Bu::Client::read( void *pData, int nBytes )
148{ 148{
149 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes ); 149 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes );
150 nRBOffset += nBytes; 150 nRBOffset += nBytes;
@@ -165,6 +165,31 @@ void Bu::Client::read( char *pData, int nBytes )
165 } 165 }
166} 166}
167 167
168void Bu::Client::peek( void *pData, int nBytes )
169{
170 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes );
171}
172
173void Bu::Client::seek( int nBytes )
174{
175 nRBOffset += nBytes;
176 if( sReadBuf.getSize()-nRBOffset == 0 )
177 {
178 sReadBuf.clear();
179 nRBOffset = 0;
180 }
181 // This is an experimental threshold, maybe I'll make this configurable
182 // later on.
183 else if(
184 (sReadBuf.getSize() >= 1024 && nRBOffset >= sReadBuf.getSize()/2) ||
185 (nRBOffset >= sReadBuf.getSize()/4)
186 )
187 {
188 sReadBuf.trimFront( nRBOffset );
189 nRBOffset = 0;
190 }
191}
192
168long Bu::Client::getInputSize() 193long Bu::Client::getInputSize()
169{ 194{
170 return sReadBuf.getSize()-nRBOffset; 195 return sReadBuf.getSize()-nRBOffset;
@@ -175,3 +200,7 @@ const Bu::Socket *Bu::Client::getSocket() const
175 return pSocket; 200 return pSocket;
176} 201}
177 202
203void Bu::Client::disconnect()
204{
205}
206