/**
* \fn tcpClient::readThis( char * data, qint64 maxSize )
* Consumes the bytes from the socket
* @param data buffer that receives the data
* @param maxSize max number of bytes to be read
* @return Returns number of bytes read
*/
qint64 tcpClient::readThis(char * data, qint64 maxSize) {
//debug.dprint( className(), __FUNCTION__, __LINE__, DBG_REDES, " > readThis() %d",maxSize);
qint64 readBuffer,readNow;
char *p;
p = data;
readBuffer = readNow = 0;
while (readBuffer < maxSize) {
disable_rp = true;
readNow=read(p, maxSize - readBuffer);
if (encryptedBytesAvailable() && readNow == 0) {
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
if (readNow < 0) {
debug.dprint( className(), __FUNCTION__, __LINE__, DBG_REDES, " Grave error reading data from the network!");
return readBuffer;
}
p += readNow;
readBuffer += readNow;
if (readBuffer < maxSize) {
qApp->processEvents();
}
}
disable_rp = false;
return readBuffer;
}
/**
* \fn tcpClient::readThis( char * data, qint64 maxSize )
* Consumes the bytes from the socket
* @param data buffer that receives the data
* @param maxSize max number of bytes to be read
* @return Returns number of bytes read
*/
qint64 tcpClient::readThis(char * data, qint64 maxSize) {
//debug.dprint( className(), __FUNCTION__, __LINE__, DBG_REDES, " > readThis() %d",maxSize);
qint64 readBuffer,readNow;
char *p;
p = data;
readBuffer = readNow = 0;
while (readBuffer < maxSize) {
disable_rp = true;
readNow=read(p, maxSize - readBuffer);
if (encryptedBytesAvailable() && readNow == 0) {
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
if (readNow < 0) {
debug.dprint( className(), __FUNCTION__, __LINE__, DBG_REDES, " Grave error reading data from the network!");
return readBuffer;
}
p += readNow;
readBuffer += readNow;
if (readBuffer < maxSize) {
qApp->processEvents();
}
}
disable_rp = false;
return readBuffer;
}
To copy to clipboard, switch view to plain text mode
readNow=read(p, maxSize - readBuffer);
readNow=read(p, maxSize - readBuffer);
To copy to clipboard, switch view to plain text mode
Bookmarks