refactor TcpServer