ofxTCPClient: setup a connection that crashed


Hello all,
I am using ofxTCPClient a lot. My use of it resemble to the examples, there not much else to do anyway to setup a connection. I use Raspberry Pi, and OF 0.10.

I realized that the first call to
ofxTCPClient::setup(string ip, int _port, bool blocking)
is OK in terms of CPU time taken,
If you have a working connection,
then you shut it up on the server side (i’m using Pure-Data, I close the window, brutally),
and reopen it (setup() is called again)

the system freeze and there is not even an ofLogError.
Should we close() the connection if disconnected from server, before setup() again ?
(EDIT: it is not enough to close() it)

There is the setup() function of ofxTCPClient.cpp:


Ok i figured it out:
The time out for the setup() function is 5 seconds by default.
(all the following in file: ofxTCPManager.cpp )

m_dwTimeoutConnect= 5;//OF_TCP_DEFAULT_TIMEOUT;

There is a Set function:

void ofxTCPManager::SetTimeoutConnect(int timeoutInSeconds) {
	m_dwTimeoutConnect= timeoutInSeconds;

this variable is used line 225:

ret = WaitSend(m_dwTimeoutConnect, 0); // args: time_t timeoutSeconds, time_t timeoutMicros

I think defining timeout in Seconds is too big, there should be a function:

void ofxTCPManager::SetTimeoutConnectMicros(int timeoutInMicroSec) // or millis converted to micros

But anyway there is a bigger issue:
When a connection was working for a specific IP:PORT, then when called
setup() again after connection was closed
It loops indefinitely by TIMEOUT waves until connection can be set again.
It should just return false, like it does when it IP:PORT was never ok before.

I hope it is clear enough, that’s a bit tricky to explain.