//--------------------------
string ofxTCPClient::receive(){

	str    = "";
	int length=-2;
	//only get data from the buffer if we don't have already some complete message
	if(tmpStr.find(messageDelimiter)==string::npos){
		memset(tmpBuff,  0, TCP_MAX_MSG_SIZE+1); //one more so there's always a \0 at the end for string concat
		length = TCPClient.Receive(tmpBuff, TCP_MAX_MSG_SIZE);
		if(length>0){ // don't copy the data if there was an error or disconnection
			removeZeros(tmpBuff,length);
			tmpStr += tmpBuff;
		}
	}

	// check for connection reset or disconnection
	if((length==-1 && (ofxNetworkCheckError() == ECONNRESET) ) || length == 0){
		close();
		if(tmpStr.length()==0) // return if there's no more data left in the buffer
			return "";
	}

	// process any available data
	if(tmpStr.find(messageDelimiter)!=string::npos){
		str=tmpStr.substr(0,tmpStr.find(messageDelimiter));
		tmpStr=tmpStr.substr(tmpStr.find(messageDelimiter)+messageDelimiter.size());
	}
	return str;
}
/*!
    \fn Convert::compareVersion(const QString& v1, const QString& v2)
 */
int Convert::compareVersion(const QString& v1, const QString& v2) {
    QRegExp removeZeros("\\.0*$");
    QStringList v1s = QString(v1).remove(removeZeros).split(".");
    QStringList v2s = QString(v2).remove(removeZeros).split(".");
    for(int i=0; i<min(v1s.size(), v2s.size()); i++) {
        if(v1s.at(i).toInt() > v2s.at(i).toInt()) {
            return 1;
        } else if (v1s.at(i).toInt() < v2s.at(i).toInt()) {
            return -1;
        }
    }
    if(v1s.size() > v2s.size()) {
        return 1;
    } else if(v1s.size() < v2s.size()) {
        return -1;
    } else {
        return 0;
    }
}