TCP server reconnect issue

hi all
i have had to implement a workaround for what i think is a bug in ofxTCPServer. i get the app running with a client no worries, but if the server app is quit and the client isn’t it needs to wait a while before the server can rebind the same port.

so I put a little loop in update to try to repeatedly check if it has to reconnect. but found that it could never recreate the server until I made the server object a pointer and deleted and created it before each attempt. now it does take a while before it can bind the port again but it does eventually work:

  
  
if (!TCP->isConnected() && ofGetElapsedTimeMillis() - last_connect > 5000) {  
		cout<<"Attempting to reconnect..."<<endl;  
		TCP->close();  
		delete TCP;  
		TCP = new ofxTCPServer();  
		TCP->setup(portIn);  
		last_connect = ofGetElapsedTimeMillis();  
}  
  

i think the prob may be in ofxTCPManager::Create()
cheers
nay

hi.

i have the same problem and your code fixed it.

it takes my computer about 25 sec before it can bind the specific port again.

thanks.
stephan.

its strange because i am opening two ports one that sends pixels and one that sends text
pixel port is 44999 and text port is 11999.
port 11999 has not binding problems and works right away, while port 44999 (also tried 11998) take a while to bind.

stephan.