// 发送结束字符buffer[0] =EOT; if (write(sock, buffer, 1) !=1) { printf("Failed to send EOT\n"); fclose(file); close(sock); return1; } // 等待接收方的ACKif (read(sock, &recv_ack, sizeof(recv_ack)) !=sizeof(recv_ack)) { printf("Failed to receive ACK\n"); fclose(file); close(sock); return1; } if (ntohs(recv_ack) !=ACK0+sequence) { printf("Failed to receive ACK\n"); fclose(file); close(sock); return1; } // 关闭文件和套接字fclose(file); close(sock); return0; }