This commit is contained in:
2025-11-12 17:05:31 -05:00
parent 58110f7d13
commit 0362ed89cd
3 changed files with 10 additions and 10 deletions
+9 -9
View File
@@ -8,8 +8,8 @@
#include <sys/socket.h>
#include <unistd.h>
#define SERVER_IP_ADDRESS "127.0.0.1"
#define SERVER_PORT 10059
#define SERVER_IP_ADDRESS "149.165.171.19"
#define SERVER_PORT 60019
#define HEADER_SIZE 4
#define CHUNK_SIZE 1024
@@ -73,12 +73,12 @@ int main(int argc, char *argv[])
// printf("Received Chunk: %s\n", chunkNum);
ack_buffer[atoi(chunkNum)] = 1; // Set buffer to RXed
// Method 1: Store chunk in buffer var
// memcpy(file_buffer + (atoi(chunkNum) - 1) * CHUNK_SIZE, buffer + HEADER_SIZE, recv_size - HEADER_SIZE);
// Method 1: Write Chunk Directly to file
fseek(file, (atoi(chunkNum) - 1) * CHUNK_SIZE, SEEK_SET);
fwrite(buffer + HEADER_SIZE, 1, recv_size - HEADER_SIZE, file);
// Method 2: Write chunk directly to file
fseek(file, (atoi(chunkNum) - 1) * CHUNK_SIZE, SEEK_SET);
fwrite(buffer + HEADER_SIZE, 1, recv_size - HEADER_SIZE, file);
// Method 2: Store chunk in buffer var
// memcpy(file_buffer + (atoi(chunkNum) - 1) * CHUNK_SIZE, buffer + HEADER_SIZE, recv_size - HEADER_SIZE);
}
}
@@ -103,10 +103,10 @@ int main(int argc, char *argv[])
// If we made it here, the file must be complete.
printf("File transfer complete!\n");
// Method 1: Write entire buffer to file
// Method 2: Write entire buffer to file
// fwrite(file_buffer, 1, CHUNK_SIZE * TOTAL_CHUNKS, file);
fclose(file);
close(socket_desc);
return 0;
}
}
Regular → Executable
BIN
View File
Binary file not shown.
+1 -1
View File
File diff suppressed because one or more lines are too long