WriteFile завершается с ошибкой ERROR_UNEXP_NET_ERR при записи в один файл из нескольких процессов. ⇐ C++
WriteFile завершается с ошибкой ERROR_UNEXP_NET_ERR при записи в один файл из нескольких процессов.
I have several pc connected to one network.
When I trying to write file with WriteFile function across network from several processes running on the different PC-s I getting ERROR_UNEXP_NET_ERR.
Details: Several PC-s does they own calculations and getting part of the common result which should be written to one file. One randomly chosen process calculates total file size and determines writing offsets for each process. This process creates the file and resize it up to calculated size.
After this I starting writing file in all processes simultaneously.
I open file on each process like this:
handle_ = ::CreateFile("////SERVERNAME//folder//filename.ext", GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); And trying to write in the cycle like this:
const size_t BUFFER_SIZE = 30 * 1024; std::vector buffer(BUFFER_SIZE); const size_t storage_size = storage_.size(); size_t internal_offset = 0; while (size_t bytes = storage_.read(buffer.data(), buffer.size(), internal_offset)) { DWORD done = 0; LARGE_INTEGER li; li.QuadPart = offset + internal_offset; OVERLAPPED overlapped; overlapped.OffsetHigh = li.HighPart; overlapped.Offset = li.LowPart; overlapped.hEvent = 0; overlapped.Pointer = 0; overlapped.Internal = 0; overlapped.InternalHigh = 0; BOOL success = ::WriteFile(handle_, buffer, (DWORD)bytes, &done, &overlapped); if (!success || done != bytes) ThrowError(FFL, "Cannot write file: {1} ({2})", filepath_, GetLastError()); // Returns error code 59 (ERROR_UNEXP_NET_ERR) internal_offset += bytes; } This approach works with file size about 7MB but fails when I trying to write 186.5GB.
I tried to do this by several different ways and tried to write file part locally on each PC. Local write works fine but all network attempts fails.
I want to know why I getting errors when trying to write across the network. I will be grateful for advice how to do this in better manner.
Источник: https://stackoverflow.com/questions/432 ... -several-p
I have several pc connected to one network.
When I trying to write file with WriteFile function across network from several processes running on the different PC-s I getting ERROR_UNEXP_NET_ERR.
Details: Several PC-s does they own calculations and getting part of the common result which should be written to one file. One randomly chosen process calculates total file size and determines writing offsets for each process. This process creates the file and resize it up to calculated size.
After this I starting writing file in all processes simultaneously.
I open file on each process like this:
handle_ = ::CreateFile("////SERVERNAME//folder//filename.ext", GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); And trying to write in the cycle like this:
const size_t BUFFER_SIZE = 30 * 1024; std::vector buffer(BUFFER_SIZE); const size_t storage_size = storage_.size(); size_t internal_offset = 0; while (size_t bytes = storage_.read(buffer.data(), buffer.size(), internal_offset)) { DWORD done = 0; LARGE_INTEGER li; li.QuadPart = offset + internal_offset; OVERLAPPED overlapped; overlapped.OffsetHigh = li.HighPart; overlapped.Offset = li.LowPart; overlapped.hEvent = 0; overlapped.Pointer = 0; overlapped.Internal = 0; overlapped.InternalHigh = 0; BOOL success = ::WriteFile(handle_, buffer, (DWORD)bytes, &done, &overlapped); if (!success || done != bytes) ThrowError(FFL, "Cannot write file: {1} ({2})", filepath_, GetLastError()); // Returns error code 59 (ERROR_UNEXP_NET_ERR) internal_offset += bytes; } This approach works with file size about 7MB but fails when I trying to write 186.5GB.
I tried to do this by several different ways and tried to write file part locally on each PC. Local write works fine but all network attempts fails.
I want to know why I getting errors when trying to write across the network. I will be grateful for advice how to do this in better manner.
Источник: https://stackoverflow.com/questions/432 ... -several-p
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
## React Native Document Ficker Error Error Error: `GuardEdresultAsynctask` не найдена
Anonymous » » в форуме Android - 0 Ответы
- 20 Просмотры
-
Последнее сообщение Anonymous
-
-
-
## React Native Document Ficker Error Error Error: `GuardEdresultAsynctask` не найдена
Anonymous » » в форуме Android - 0 Ответы
- 20 Просмотры
-
Последнее сообщение Anonymous
-