More TCP-related fixes and tweaks to ping timing, resynchronize, and startup.
Finally fixed TCP sockets.