remove dead code and fix static correctness in tcpclient

This removes some unused code, and declares functions that don't need external linkage to be static.