Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. InternetWriteFile sync/async?

InternetWriteFile sync/async?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++sysadminjson
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CaesarCZ
    wrote on last edited by
    #1

    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...

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups