ofxTCPClient is it threaded ?

Hi,
I’m creating a tcp client, and i wish to know if ofxTCPClient is already threaded, or if i need to create a thread for it ?
Regards,
Cgiles

It’s not but you might want to check out Arturos ofxHTTPUtils https://github.com/arturoc/ofxHttpUtils because that does provide threading for clients though it’s specifically around using form submission etc.

Thanks, it’s been an interesting source of inspiration,
there is my class, it works, but i certainly do more simple or efficient :

  
/*  
 * ofTcpClientThread.h  
 *  
 *  Created on: 7 sept. 2013  
 *      Author: gilles  
 */  
  
#ifndef OFTCPCLIENTTHREAD_H_  
#define OFTCPCLIENTTHREAD_H_  
  
#include "ofMain.h"  
#include "ofxNetwork.h"  
// my thread for the tcp client, sure it can be better, but I'm a padawan  
class ofTcpClientThread: public ofThread {  
  
	void threadedFunction() {  
		// while(isThreadRunning()) does the thread loop, without that, it work once...  
		while (isThreadRunning()) {  
// check if my client is connected  
			if (myClientTcp.isConnected()) {  
// lock the ressource  
				lock();  
				// let know the main thread we are online  
				isConnected = true;  
// check if the main thread already read the received data, without that  
				// without that the main thread is unable to get the data, strange...  
				if (isChecked) {  
					rawReceived = myClientTcp.receive();  
  
					isChecked = false;  
				}  
				// unock the ressource  
				unlock();  
			} else {  
// if client is unconnected  
  
				myClientTcp.setup(ip, 11211);  
				// how the message are ended, you must define it.  
				myClientTcp.setMessageDelimiter("}");  
				// lock the ressource  
				lock();  
				// let know is unconnected  
				isConnected = false;  
				// unlock the ressource  
				unlock();  
			}  
  
		}  
	}  
	ofxTCPClient myClientTcp;  
	// i must define this variables as public, without that i got an error   
	// if i try to access them since the main thread, i got an error about private access  
public:  
	string rawReceived = "";  
public:  
	bool isConnected = false;  
public:  
	bool isChecked = true;  
	string ip = "192.168.0.42";  
};  
  
#endif /* OFTCPCLIENTTHREAD_H_ */