Client
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user