Hello! Now there is the last stage in my task. The server normally sends the blocks of the file to the client. It remains to glue them on the client side. The question is still purely theoretical: how will the client understand which file to create (with what extension) in order to record blocks received from the server?
Сервер //Отправка файла int i = 0; int b; int a = atoi(buffer); char * buff = new char[a]; d: while(!feof(in)) { b = fread(&buff[0],1,a,in); send(client_socket,&buff[0],b,0); i++; printf("Send %d block file \n", i); recv(client_socket, buffer, BUFFER_SIZE ,0); if (!strcmp(&buffer[0], "Принимаю поблочно файл!")) goto d; } fclose(in); printf("File successfully send clienty\n"); system("PAUSE"); Клиент //Прием файла else { f: int nbytes = recv( my_socket, &buff[0], sizeof(buff), 0 ); if ( nbytes == 0) { printf("\nПередача файла завершена\n"); system("pause"); fclose(RecFile); return -1; } if (nbytes < 0) { printf("Ошибка в передаче файла \n"); return -1; } RecFile = fopen ("C:/receve.txt","at"); fwrite(buff, 1, strlen(buff), RecFile); fclose(RecFile); strcpy(&buff1[0], "Принимаю поблочно файл!"); int n1 = strlen(buff1); send(my_socket, buff1, (n1-1), 0); goto f; } system("pause"); }