summaryrefslogtreecommitdiff
path: root/src/connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/connection.cpp')
-rw-r--r--src/connection.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/connection.cpp b/src/connection.cpp
index f382d82..a5fac5b 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -13,6 +13,9 @@
13#include <errno.h> 13#include <errno.h>
14#include "exceptions.h" 14#include "exceptions.h"
15 15
16// Read buffer size...maybe fix wierd issues...
17#define RBS (1024*10)
18
16Connection::Connection() 19Connection::Connection()
17{ 20{
18 nSocket = -1; 21 nSocket = -1;
@@ -201,15 +204,15 @@ bool Connection::open( const char *sAddr, int nPort )
201 204
202int Connection::readInput() 205int Connection::readInput()
203{ 206{
204 char buffer[2048]; 207 char buffer[RBS];
205 int nbytes; 208 int nbytes;
206 int nTotalRead=0; 209 int nTotalRead=0;
207 210
208 for(;;) 211 for(;;)
209 { 212 {
210 //memset( buffer, 0, 2048 ); 213 //memset( buffer, 0, RBS );
211 214
212 nbytes = read( nSocket, buffer, 2048 ); 215 nbytes = read( nSocket, buffer, RBS );
213 if( nbytes < 0 && errno != 0 && errno != EAGAIN ) 216 if( nbytes < 0 && errno != 0 && errno != EAGAIN )
214 { 217 {
215 printf("errno: %d, %s\n", errno, strerror( errno ) ); 218 printf("errno: %d, %s\n", errno, strerror( errno ) );
@@ -224,12 +227,12 @@ int Connection::readInput()
224 nTotalRead += nbytes; 227 nTotalRead += nbytes;
225 appendInput( buffer, nbytes ); 228 appendInput( buffer, nbytes );
226 /* Data read. */ 229 /* Data read. */
227 if( nbytes < 2048 ) 230 if( nbytes < RBS )
228 { 231 {
229 break; 232 break;
230 } 233 }
231 234
232 /* New test, if data is divisible by 2048 bytes on some libs the 235 /* New test, if data is divisible by RBS bytes on some libs the
233 * read could block, this keeps it from happening. 236 * read could block, this keeps it from happening.
234 */ 237 */
235 { 238 {
@@ -358,7 +361,7 @@ bool Connection::clearInput()
358 361
359bool Connection::writeOutput() 362bool Connection::writeOutput()
360{ 363{
361 //int nBytes = TEMP_FAILURE_RETRY( write( nSocket, xOutputBuf.getData(), min( 2048, xOutputBuf.getLength() ) ) ); 364 //int nBytes = TEMP_FAILURE_RETRY( write( nSocket, xOutputBuf.getData(), min( RBS, xOutputBuf.getLength() ) ) );
362 int nBytes = TEMP_FAILURE_RETRY( write( nSocket, xOutputBuf.getData(), xOutputBuf.getLength() ) ); 365 int nBytes = TEMP_FAILURE_RETRY( write( nSocket, xOutputBuf.getData(), xOutputBuf.getLength() ) );
363 if( nBytes < 0 ) 366 if( nBytes < 0 )
364 { 367 {