mirror of
https://github.com/fumiama/simple-kanban.git
synced 2026-06-28 15:10:27 +08:00
修复linux sendfile语法问题
This commit is contained in:
2
client.c
2
client.c
@@ -84,7 +84,7 @@ int main(int argc,char *argv[]) { //usage: ./client host port
|
|||||||
else puts("Send file error.");
|
else puts("Send file error.");
|
||||||
#else
|
#else
|
||||||
send(sockfd, &file_size, sizeof(uint32_t), 0);
|
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.");
|
else puts("Send file error.");
|
||||||
#endif
|
#endif
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|||||||
4
server.c
4
server.c
@@ -136,9 +136,9 @@ int sendAll(char* file_path, THREADTIMER *timer) {
|
|||||||
sendfile(fileno(fp), timer->accept_fd, 0, &len, &hdtr, 0);
|
sendfile(fileno(fp), timer->accept_fd, 0, &len, &hdtr, 0);
|
||||||
#else
|
#else
|
||||||
send(timer->accept_fd, &file_size, sizeof(uint32_t), 0);
|
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
|
#endif
|
||||||
printf("Send %lld bytes.", len);
|
printf("Send %lld bytes.\n", len);
|
||||||
closeFile(fp);
|
closeFile(fp);
|
||||||
timer->is_open = 0;
|
timer->is_open = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user