diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b666903..c8d5da2 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -13,10 +13,8 @@
-
-
+
-
@@ -45,8 +43,8 @@
-
-
+
+
@@ -54,6 +52,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -139,6 +155,11 @@
+
+
+
+
+
@@ -182,12 +203,20 @@
-
+
+
+ 1572716481980
+
+
+
+ 1572716481981
+
+
-
+
@@ -198,7 +227,7 @@
-
+
@@ -220,12 +249,16 @@
+
+
+
+
file://$PROJECT_DIR$/main.c
- 77
+ 81
@@ -290,10 +323,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/cmake-build-debug/CMakeFiles/ProjektDSIK.dir/C.includecache b/cmake-build-debug/CMakeFiles/ProjektDSIK.dir/C.includecache
index 9bcf79a..b6ee3a4 100644
--- a/cmake-build-debug/CMakeFiles/ProjektDSIK.dir/C.includecache
+++ b/cmake-build-debug/CMakeFiles/ProjektDSIK.dir/C.includecache
@@ -67,6 +67,8 @@ netdb.h
-
pthread.h
-
+fcntl.h
+-
EasySockets.h
/home/emile/DSIK_C/EasySockets.h
Game.h
diff --git a/cmake-build-debug/CMakeFiles/ProjektDSIK.dir/main.c.o b/cmake-build-debug/CMakeFiles/ProjektDSIK.dir/main.c.o
index 440524e..bba05f4 100644
Binary files a/cmake-build-debug/CMakeFiles/ProjektDSIK.dir/main.c.o and b/cmake-build-debug/CMakeFiles/ProjektDSIK.dir/main.c.o differ
diff --git a/cmake-build-debug/ProjektDSIK b/cmake-build-debug/ProjektDSIK
index f118acf..7bad82b 100755
Binary files a/cmake-build-debug/ProjektDSIK and b/cmake-build-debug/ProjektDSIK differ
diff --git a/main.c b/main.c
index 45b2030..bb2ca9e 100644
--- a/main.c
+++ b/main.c
@@ -8,6 +8,7 @@
#include
#include
#include
+#include
#include "EasySockets.h"
#include "Game.h"
#include "LinkedList.h"
@@ -42,6 +43,7 @@ void InterpretReceivedSignal(Player* p, const char* buffer, int len, bool* fileS
}else if (buffer[0] == 'f'){
*fileSwitch=true;
}
+
}
}
int series =0;
@@ -72,17 +74,35 @@ void* PlayerDataReaderThread(void* arg){
printf("%d", p->points);
socklen_t size = sizeof(p->incoming);
bool isFile=false;
+ FILE* fileHandle = NULL;
while (true) {
- int s = recv(p->connectionId, buffer, 1000, 0);
+ int s = recv(p->connectionId, buffer, 550, 0);
if (s>0) {
- InterpretReceivedSignal(p, buffer, 1000,&isFile);
+ if (!isFile)
+ {InterpretReceivedSignal(p, buffer, 550,&isFile);
+ continue;}
if (isFile){
+ printf("is file \n");
+ if (fileHandle==NULL) fileHandle=fopen("recv", "w+");
//receiving the file in parts
+ printf("buffer content: %s\n", buffer);
+ fwrite(buffer,s,1,fileHandle);
+ if (s<550){
+ printf("ended receiving file...\n");
+ //if not data was received
+ fflush(fileHandle);
+ fclose(fileHandle);
+ isFile=false;
+ }
continue;
}
if (state >0)
UpdateStateToClients();
+
+ }else{
+
}
+
}
}