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

再次适配linux

This commit is contained in:
fumiama
2021-05-03 00:18:06 +08:00
parent 0a0a449a8f
commit ced6a6afca
2 changed files with 11 additions and 3 deletions

View File

@@ -47,6 +47,10 @@ int main(int argc,char *argv[]) { //usage: ./client host port
ssize_t numbytes;
puts("break!");
while((sockfd = socket(AF_INET,SOCK_STREAM,0)) == -1);
#if !__APPLE__
int reuse = 1;
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
#endif
puts("Get sockfd");
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(atoi(argv[2]));
@@ -84,7 +88,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(sockfd, fileno(fp), &len, htonl(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);