Hi,
I try to run the ofxTCPServer in a seperate thread like this:
class ViflowTcpServer : public ofThread
{
public:
ViflowTcpServer()
{
ofxTCPSettings tsettings(12000);
tsettings.blocking = true;
server.setup(tsettings);
server.setVerbose(true);
};
ofxTCPServer server;
void threadedFunction();
};
The threadedFunction looks like this, taken from the example:
void ViflowTcpServer::threadedFunction()
{
bool forever = true;
while (forever)
{
for (unsigned int i = 0; i < (unsigned int)server.getLastID(); i++)
{
if (!server.isClientConnected(i))continue;
string str;
string tmp;
do {
str += tmp;
tmp = server.receive(i);
} while (tmp != "");
if (str.length() > 0)
{
ofLog() << "Received: " << str << "\n";
}
}
ofLog() << "Doing something...";
sleep(1000);
}
}
I expected that the ofxTCPServer is blocking until it receives something if I set “blocking” in the settings to true, but this is not the case. How can I setup the ofxTCPServer in a way it waits until a client connects?