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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WSACleanup delays when called how can I get around this?

WSACleanup delays when called how can I get around this?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 2 Posters 2 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.
  • U Offline
    U Offline
    User 4333622
    wrote on last edited by
    #1

    Hi, Originally the issue was that connect() has a 20 second timeout in it. I switched to some code I found that makes the connect() not blocking, and I can certainly get program control back in 5 seconds, but this module needs to load and unload and I can't get it to unload without the full 20s wait because WSACleanup must wait for that original non blocking connect to complete before it releases. I've tried various linger options and calling or not calling shutdown and closesocket, but nothing makes a difference. I don't want to not call WSACleanup as I figure that might be a big deal. Is there a way to tell winsock to stop trying to connect so it doesn't wait out the 20s? Thanks, Alan

    G 1 Reply Last reply
    0
    • U User 4333622

      Hi, Originally the issue was that connect() has a 20 second timeout in it. I switched to some code I found that makes the connect() not blocking, and I can certainly get program control back in 5 seconds, but this module needs to load and unload and I can't get it to unload without the full 20s wait because WSACleanup must wait for that original non blocking connect to complete before it releases. I've tried various linger options and calling or not calling shutdown and closesocket, but nothing makes a difference. I don't want to not call WSACleanup as I figure that might be a big deal. Is there a way to tell winsock to stop trying to connect so it doesn't wait out the 20s? Thanks, Alan

      G Offline
      G Offline
      Gisle Vanem
      wrote on last edited by
      #2

      A non-blocking socket should return in like 5 micro-sec. Not 5 sec. How did you make the socket non-blocking?

      -- Gisle V.

      U 1 Reply Last reply
      0
      • G Gisle Vanem

        A non-blocking socket should return in like 5 micro-sec. Not 5 sec. How did you make the socket non-blocking?

        -- Gisle V.

        U Offline
        U Offline
        User 4333622
        wrote on last edited by
        #3

        Sorry about the confusion - yes I am using select to make the timeout 5s. That is the timeout I would like and that part is working fine. It is the WSACleanup that isn't quickly returning that is the problem. I am hoping there is something I can do to shutdown the connect attempt before I call WSACleanup that would stop WSACleanup from taking the remaining 15s...

        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