fix the bug of Chinese chars display and update the tcpServer to exit safely