File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ void run(cxxopts::ParseResult &options) {
8383 if (ttl <= 0 ) return ;
8484
8585 // If Sender finish transfering check missing parts every 1 sec
86- if (finish) checkParts ();
86+ if (finish && file != nullptr ) checkParts ();
8787
8888 if (length <= 0 ) {
8989 ttl--;
@@ -102,13 +102,13 @@ void run(cxxopts::ParseResult &options) {
102102
103103 std::cout << " Receive information about new file size: " << file_length << std::endl;
104104 std::cout << " Number of parts: " << int ((float )file_length / (float )mtu + 0.5 ) << std::endl;
105- } else if (strncmp (buffer, " TRANSFER" , 8 ) == 0 ) {
105+ } else if (strncmp (buffer, " TRANSFER" , 8 ) == 0 && file != nullptr ) {
106106 int part = Utils::getNumberFromBytes (buffer + 8 , 4 ); // Read section "index"
107107 int size = Utils::getNumberFromBytes (buffer + 12 , 4 ); // Read section "size"
108108 parts.insert (part);
109109 std::cout << " Receive " << part << " part with size " << size << std::endl;
110110
111- memcpy (file + part * options[ " mtu" ]. as < int >() , buffer + 16 , size);
111+ memcpy (file + part * mtu, buffer + 16 , size);
112112 } else if (strncmp (buffer, " FINISH" , 6 ) == 0 ) {
113113 // If receiver didn't receive a finish message
114114 if (!finish) {
You can’t perform that action at this time.
0 commit comments