1
0
mirror of https://github.com/fumiama/simple-kanban.git synced 2026-06-11 20:20:31 +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

@@ -76,8 +76,12 @@ int bindServer(uint16_t port, u_int try_times) {
server_addr.sin_port = htons(port);
server_addr.sin_addr.s_addr = INADDR_ANY;
bzero(&(server_addr.sin_zero), 8);
fd = socket(AF_INET, SOCK_STREAM, 0);
#if !__APPLE__
int reuse = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
#endif
while(!~(result = bind(fd, (struct sockaddr *)&server_addr, struct_len)) && fail_count++ < try_times) sleep(1);
if(!~result && fail_count >= try_times) {
puts("Bind server failure!");
@@ -137,7 +141,7 @@ 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(timer->accept_fd, fileno(fp), &len, htonl(file_size));
sendfile(timer->accept_fd, fileno(fp), &len, file_size);
#endif
printf("Send %lld bytes.\n", len);
closeFile(fp);