CLI: TCPF: Move action logic out of the server implementation file

TCPF becomes harder to understand. Simplify by splitting the files.
CLI: TCPF: Refactor the server

Implement the tcpf_select function to make loops shorter and logic cleaner.