1
0
mirror of https://github.com/fumiama/simple-kanban.git synced 2026-06-12 12:50:25 +08:00

修正大端系统下的错误

This commit is contained in:
fumiama
2021-05-07 22:53:18 +08:00
parent a07876cb33
commit 77fc742f18
4 changed files with 24 additions and 13 deletions

View File

@@ -43,7 +43,7 @@ off_t size_of_file(const char* fname) {
else return -1;
}
int main(int argc,char *argv[]) { //usage: ./client host port [-r]
int main(int argc,char *argv[]) { //usage: ./client host port
ssize_t numbytes;
puts("break!");
while((sockfd = socket(AF_INET,SOCK_STREAM,0)) == -1);
@@ -75,7 +75,6 @@ int main(int argc,char *argv[]) { //usage: ./client host port [-r]
off_t len = 0;
file_size = (uint32_t)size_of_file(buf);
#if __APPLE__
if(argc == 4) file_size = htonl(file_size);
struct iovec headers;
headers.iov_base = &file_size;
headers.iov_len = sizeof(uint32_t);
@@ -86,10 +85,7 @@ int main(int argc,char *argv[]) { //usage: ./client host port [-r]
if(!sendfile(fileno(fp), sockfd, 0, &len, &hdtr, 0)) puts("Send file success.");
else puts("Send file error.");
#else
if(argc == 4) {
uint32_t fs = htonl(file_size);
send(sockfd, &fs, sizeof(uint32_t), 0);
} else send(sockfd, &file_size, sizeof(uint32_t), 0);
send(sockfd, &file_size, sizeof(uint32_t), 0);
if(!sendfile(sockfd, fileno(fp), &len, file_size)) puts("Send file success.");
else puts("Send file error.");
#endif