فهرست منبع

add synchronisation with client

Helmut Pozimski 4 سال پیش
والد
کامیت
d06d0b0ec4
1فایلهای تغییر یافته به همراه9 افزوده شده و 0 حذف شده
  1. 9 0
      src/main.c

+ 9 - 0
src/main.c

@@ -23,6 +23,11 @@ typedef struct {
 	uint32_t bits;
 } sync_information;
 
+typedef struct {
+	char ack[4];
+	sync_information sync;
+} sync_ack;
+
 /*
  * Function: construct_file_path
  * ----------------------------------------
@@ -67,6 +72,7 @@ int main(int argc, char **argv) {
 	uint8_t buffer[BUF_SIZE];
 	wavfile * file;
 	char * file_path;
+	sync_ack ack_packet;
 	while ((opt = getopt(argc, argv, "i:p:d:")) != -1) {
 		switch(opt) {
 			case 'i':
@@ -107,6 +113,9 @@ int main(int argc, char **argv) {
 		construct_file_path(directory, file_path);
 		printf("Current file path: %s\n", file_path);
 		file = wavfile_create(file_path, 1, sync.sample_rate, sync.bits);
+		strncpy(ack_packet.ack,"ACK", 4);
+		ack_packet.sync = sync;
+		send(conn, &ack_packet, sizeof(ack_packet), 0);
 		if (file == NULL) {
 			printf("Error creating new file\n");
 			close(conn);