ofxNetwork Bug

I had a problem with network packets going missing. I tracked the problem down to the ofxTCPClient:receive() function.

If the client is really fast this function ends up receiving a string like


in this case the receive() function returns only the first command and the second is lost.

I got around the problem with the following code…

string CassiusSocket::process(Punches * boxingBag){  
    string cmd = "";  
	//for each connected client lets get the data being sent and lets print it to the screen  
	for(int i = 0; i < TCP.getNumClients(); i++){  
		//if we don't have a string allocated yet  
		//lets create one  
		if(i >= storeText.size() ){  
			storeText.push_back( "nothing" );  
		//we only want to update the text we have recieved if there is data  
		string tmpStr = getRawTCPMessage(&TCP.TCPConnections[i]);  
		string sSTR_END_MSG = "[/TCP]";  
		int pos = tmpStr.find(sSTR_END_MSG, 0);  
		while(pos >= 0 && tmpStr.length() > 0){  
			string command = tmpStr.substr(0, pos);  
			tmpStr = tmpStr.substr(pos + sSTR_END_MSG.length());  
			pos = tmpStr.find(STR_END_MSG, 0);  
			if(command.length() > 0){  
					std::cout << command << "\n";  
				storeText[i] = command;  
					printf("SendStatus: %s\n", status.c_str());  
					TCP.send(i, status);  
				}else if(command=="new"){  
				}else if(command=="save"){  
					cmd = "save";  
				}else if(command=="ping"){  
					TCP.send(i, "pong");  
	return cmd;// I only have one client so this is ok  
string CassiusSocket::getRawTCPMessage(ofxTCPClient * myClient){  
	string tmpStr = "";  
	char tmpBuff[512];  
	//by default get all data in the buffer  
	while( myClient->receiveRawBytes(tmpBuff, 512) > 0 ){  
		tmpStr += tmpBuff;  
		memset(tmpBuff,  0, TCP_MAX_MSG_SIZE);  
	return tmpStr;  

Hey thanks for that!
We will get that fix in the next version which should be out soon!


Still have the same problem here.
I think this is simple to fix, just return the first command, in the next cicle return the second.
There is no problem this micro delay.


this was fixed a long time ago, are you sure it’s the same problem? can you post a simple example that reproduces the error?

Great Arturo,

I see it, sorry.
But I dont know what happens about the lost packages that I have.
Maybe is the TCP_MAX_SIZE 512?


tcp doesn’t loose pacakages, no matter what the package size is so it’s either a bug in OF or a bug in your code. If you could post a little example that shows the bug that would make it easier to help you

Hi Arturo,

thanks for the Help!

I asked for a solution here:

And I solved my problem by sending a confirmation at the server that received the message.