Thanks for getting back. I’m sending a message formatted like this “mouseX=123**mouseY=456”
Here’s the code in the update method in the client application:
if(isConnected)
{
sentMsg = "mouseX=" + ofToString(ofGetMouseX()) + "**mouseY=" + ofToString(ofGetMouseY());
if(tcpClient.send(sentMsg))
{
//if data has been sent lets update our text
string str = tcpClient.receive();
if( str.length() > 0 )
{
receivedMsg = str;
}
}
}
And this is in the server application:
for(int i = 0; i < tcpServer.getLastID(); i++)
{
if(!tcpServer.isClientConnected(i))continue;
//calculate where to draw the text
int xPos = 15;
int yPos = 100 + (12 * i * 4);
//get the ip and port of the client
string port = ofToString(tcpServer.getClientPort(i));
string ip = tcpServer.getClientIP(i);
string info = "client "+ofToString(i)+" -connected from "+ip+" \non port: "+port;
//we only want to update the text we have recieved there is data
string str = "from client - "+tcpServer.receive(0);
printf("frame = %i, str = %s \n", ofGetFrameNum(), str.c_str());
//draw the info text and the received text bellow it
ofDrawBitmapString(info, xPos, yPos);
ofDrawBitmapString(str, xPos, yPos + 50 + (i*50));
}
To illustrate my issue further, the printf function in the server code produces the following results:
frame = 988, str = from client - mouseX=26
frame = 989, str = from client - mouseY=32
frame = 990, str = from client - mouseX=51
frame = 991, str = from client - mouseY=62
frame = 992, str = from client - mouseX=96
frame = 993, str = from client - mouseY=116
As you can see, the application is only allowing one value to be received per frame, which is causing a queue of data somewhere.
@Arturo, if I understand you correctly, the delimiter is used purely to end the message, not to separate the values in a single packet. Is this correct? If so I need to write a function to split the string into an array.
I’ve attached a couple of stripped down projects.
TCP_Test.zip