improved design of tcp_server