recv(comm_socket,recv_buff, sizeof(recv_buff), 0); /*receiveclient's command*/改成int ret = recv(comm_socket,recv_buff, sizeof(recv_buff), 0); /*receiveclient's command*/if ret == -1 || ret == 0 break== -1 表示出错, =0 表示 socket 已经关闭。