InternetWriteFile sync/async?
-
Hi, first of all, I do this in pure API, but it's all wrapped up in MFC so you shouldn't really have any problems :) I need to upload some memory data to ftp. I open the internet and connect (InternetOpen, InternetConnect), I open a ftp file using FtpOpenFile... so far I guess it's all right, no errors, FTP server's log looks quite okay. (btw. I do with GENERIC_WRITE). Then I try to upload data using InternetWriteFile(handle_from_ftpopenfile, buffer, length_of_the_buffer, &written); the problem is that when I walk thru the code or call sleep to suspend the thread before calling the InternetCloseHandle for a while (which is weird. It shouldn't do anything then unless it uploads in a separate thread, but what that written parameter is for then?) the file uploads okay. If I just run it, the file is created but is empty (0 bytes). In both cases the InternetWriteFile returns false, GetLastError is 0, InternetGetLastResponseInfo is 0 (and error buffer is ""). I guess the cause might be the InternetCloseHandle (I've read somewhere that it cancels the operations pending. But the InternetWriteFile should be synchronous, or not?). So what's up and how can I determine when it's safe to call InternetCloseHandle...