From 3ac2667c428337aa44dcc51757713d9468a48cb7 Mon Sep 17 00:00:00 2001 From: fumiama Date: Sun, 2 May 2021 23:59:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dlinux=20sendfile=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.c | 2 +- server.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client.c b/client.c index f25a249..22a2d5e 100644 --- a/client.c +++ b/client.c @@ -84,7 +84,7 @@ int main(int argc,char *argv[]) { //usage: ./client host port else puts("Send file error."); #else send(sockfd, &file_size, sizeof(uint32_t), 0); - if(!sendfile(fileno(fp), sockfd, &len, file_size)) puts("Send file success."); + if(!sendfile(sockfd, fileno(fp), &len, file_size)) puts("Send file success."); else puts("Send file error."); #endif fclose(fp); diff --git a/server.c b/server.c index fbde2cd..d7e5366 100644 --- a/server.c +++ b/server.c @@ -136,9 +136,9 @@ int sendAll(char* file_path, THREADTIMER *timer) { sendfile(fileno(fp), timer->accept_fd, 0, &len, &hdtr, 0); #else send(timer->accept_fd, &file_size, sizeof(uint32_t), 0); - sendfile(fileno(fp), timer->accept_fd, &len, file_size); + sendfile(timer->accept_fd, fileno(fp), &len, file_size); #endif - printf("Send %lld bytes.", len); + printf("Send %lld bytes.\n", len); closeFile(fp); timer->is_open = 0; }