TransmitFile-Limit bei sizeof(WORD)?
-
Hallo!
Für meinen HTTP-Server möchte ich die TransferFile-Extension benutzen, jedoch gibt mir GetQueuedCompletionStatus() den Fehler ERROR_BAD_COMMAND zurück, sobald ich mit TransferFile mehr als sizeof(WORD) (bei mir 65536) Bytes, z.B. aus großen Bildern, senden will.
Woran kann das liegen?
-
sizeof(WORD) (bei mir 65536)
sizeof(WORD) ist auf den meisten Plattformen 2.
-
Hoppla, das war natürlich Unfug. Anyway, das Limit liegt bei 65536, und das begreife ich nicht, da die MSDN so ein Limit gar nicht setzt. Der Code:
static LPFN_TRANSMITFILE transmit_file; if(!transmit_file) { GUID id = WSAID_TRANSMITFILE; DWORD bytes = 0; if(WSAIoctl(destination->handle(), SIO_GET_EXTENSION_FUNCTION_POINTER, &id, sizeof id, &transmit_file, sizeof transmit_file, &bytes, 0, 0) == SOCKET_ERROR) throw net_error("TransmitFile() extension loading error"); } operation* op = create_operation(); op->operation_type = send; op->socket = destination; if(transmit_file(destination->handle(), file, 0, 0, &op->overlapped, 0, TF_USE_DEFAULT_WORKER) == FALSE) { switch(GetLastError()) { case WSA_IO_PENDING: break; case WSAEDISCON: case WSAECONNRESET: { operation* op = create_operation(); op->socket = destination; op->operation_type = disconnect; destination->queue_->enqueue(op); break; } default: CloseHandle(file); throw net_error("send file call error"); } }