Frame Synchronization over LAN using ofxNetwork (Similar to MPE)

i am trying to synchronize video capture in different computers over the lan. For this i am using Most Pixel Ever’s method to send packets to the server, once all the clients have sent their packets, the server tells them to grab the next frame.
It is working fine over both UDP and TCP. The problem i am facing is with the reconnection.
i have a toggle button for the client to connect to the server. When it is switched off and it tries to reconnect, it fails.
i have also tried disconnectClient() function is ofxTCPServer. When i use this, and it reconnects - it says client0 connected on port 0. And doesn’t receive any packets.
Also both my server and client are running on threads. So if i try to send a disconnect packet to all the clients and restart the server. The server restarts before the packet could reach all the clients. If i add ofSleepMillis() to it, it will no longer be dynamic.

anyone knows how to reconnect properly.