rendered paste bodybool ByteBuffer::PutToSocket(int socket) {
CHECK_READ_WRITE_SIZE_CURSORS;
bool result;
int32_t sent=send(socket, _pBuffer+_readCursor, _writeCursor-_readCursor, 0);
if(sent<=0) {
if(errno==EAGAIN){
DEBUG("Unable to send %d bytes of data. Retry count is %d",_writeCursor-_readCursor,_sendRetryCount);
_sendRetryCount++;
if(_sendRetryCount>MAX_SEND_RETRY_COUNT){
FATAL("MAX_SEND_RETRY_COUNT reached: %d", MAX_SEND_RETRY_COUNT);
return false;
}
else{
return true;
}
}
else{
FATAL("Permanent error while trying to send %d bytes of data: %d",_writeCursor-_readCursor,errno);
return false;
}
}
else {
_sendRetryCount=0;
_readCursor+=sent;
result=true;
}
if(result)
Realloc(0);
CHECK_READ_WRITE_SIZE_CURSORS;
return result;
}