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. CAsyncSocket ::OnReceive() missed calls

CAsyncSocket ::OnReceive() missed calls

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasesysadmindebuggingperformance
5 Posts 3 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.
  • N Offline
    N Offline
    neilsolent
    wrote on last edited by
    #1

    I am developing a network application using CAsyncSocket. I have OnReceive() overridden to read data (as does everyone I guess!) All is fine - the application is successfully receiving data from the peer - until suddenly the calls to OnReceive() cease. For debugging, I also call ioctlsocket() with FIONREAD, and this reports that there are zero bytes in the network read buffer when the OnReceive() calls stop. However, if I force a new call to OnReceive() this proves that definitely IS data available - as more data is read. Also, calling AsyncSelect() when the stall occurs, DOES trigger a new call to OnReceive(). However I don't want to schedule calls to AsyncSelect() - I shouldn't have to - and that would cause a performance hit anyway. The stall occurs regularly - usually at least once every minute. An occasional missed call to OnReceive() would be tolerable, but this is ridiculous! There are similar issues noted on the internet, e.g. http://groups.google.co.uk/group/microsoft.public.vc.mfc/browse\_thread/thread/26f6d6cb0151c2ad/6ed6994c7bcdf45c?lnk=st&q=&rnum=3&hl=en#6ed6994c7bcdf45c .. but I have not seen a proper explanation, let alone resolution, and I have run out of things to try / debug. Any help very gratefully received! :confused:

    cheers, Neil

    S 1 Reply Last reply
    0
    • N neilsolent

      I am developing a network application using CAsyncSocket. I have OnReceive() overridden to read data (as does everyone I guess!) All is fine - the application is successfully receiving data from the peer - until suddenly the calls to OnReceive() cease. For debugging, I also call ioctlsocket() with FIONREAD, and this reports that there are zero bytes in the network read buffer when the OnReceive() calls stop. However, if I force a new call to OnReceive() this proves that definitely IS data available - as more data is read. Also, calling AsyncSelect() when the stall occurs, DOES trigger a new call to OnReceive(). However I don't want to schedule calls to AsyncSelect() - I shouldn't have to - and that would cause a performance hit anyway. The stall occurs regularly - usually at least once every minute. An occasional missed call to OnReceive() would be tolerable, but this is ridiculous! There are similar issues noted on the internet, e.g. http://groups.google.co.uk/group/microsoft.public.vc.mfc/browse\_thread/thread/26f6d6cb0151c2ad/6ed6994c7bcdf45c?lnk=st&q=&rnum=3&hl=en#6ed6994c7bcdf45c .. but I have not seen a proper explanation, let alone resolution, and I have run out of things to try / debug. Any help very gratefully received! :confused:

      cheers, Neil

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      I might be misremembering this, but doesn't there have to be a read pending before receive notifications are sent? (Normally I use raw sockets, or a custom class to manage TCP/UDP stuff, so my memory is a bit hazy on this one)

      Steve S Developer for hire

      N 1 Reply Last reply
      0
      • S Steve S

        I might be misremembering this, but doesn't there have to be a read pending before receive notifications are sent? (Normally I use raw sockets, or a custom class to manage TCP/UDP stuff, so my memory is a bit hazy on this one)

        Steve S Developer for hire

        N Offline
        N Offline
        neilsolent
        wrote on last edited by
        #3

        Hi Steve Thanks for replying. I think a read IS pending. The problem is that the socket seems to "go to sleep" and it is necessary to call AsyncSelect() to make the framework realise data can be read. cheers, Neil

        cheers, Neil

        M 1 Reply Last reply
        0
        • N neilsolent

          Hi Steve Thanks for replying. I think a read IS pending. The problem is that the socket seems to "go to sleep" and it is necessary to call AsyncSelect() to make the framework realise data can be read. cheers, Neil

          cheers, Neil

          M Offline
          M Offline
          Moak
          wrote on last edited by
          #4

          I never came across this problem in my network applications. I wonder how your code in the OnReceive() handler looks like?

          N 1 Reply Last reply
          0
          • M Moak

            I never came across this problem in my network applications. I wonder how your code in the OnReceive() handler looks like?

            N Offline
            N Offline
            neilsolent
            wrote on last edited by
            #5

            No, I think you are right. At the time I was using code from OpenSSL, and I think that causes some strange things to happen. I changed my algorithm, and now it is fully working. So I don't think there really is a bug with the MS software, you just have to be careful with these functions, and call them at the right times etc.

            cheers, Neil

            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