CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    293

    Question Problem with IOCP

    Hi,

    In order to build a server I use IOCP by calling AcceptEx() and bind every socket by calling 'BindIoCompletionCallback()'.

    When Client connects and sends a message I receive it by calling 'ReadFile()'.

    Now for my problem:

    I defined buffer of size 1024 for 'AcceptEx' and for 'ReadFile' .

    and if, for instance, the Client sends the Server a buffer of size 2500 bytes, it gets it in small chunks:

    960 bytes
    960 bytes
    580 bytes

    which is great - until now everything works great, BUT!! if the Client sends another buffer of 2500 bytes the Sever, for some reason, gets it by chunks of 580 bytes (which is the exact size which he got the last chunk of the previous buffer) instead of getting it by chunks of 960 bytes.

    btw: 960 is because : 1024 - sizeof(sockaddr_in)+16)*2

    and this goes on and on it reads very small chunks and never goes back to reading 960 bytes, any idea why?? what am I doing wrong ??

    Hope I made myself clear,


    Thanks for reading and paying attention.

    BYE.

  2. #2
    Join Date
    May 2009
    Posts
    4

    Re: Problem with IOCP

    If you know that client will send you around 2500 why not use bigger buffer?
    Try to change your buffer size to receive 1249 bytes. Will it receive the second message in 2 byte frames ?

  3. #3
    Join Date
    Jul 2005
    Posts
    185

    Re: Problem with IOCP

    It must be your code requesting to read as many bytes as the last chunk..

    Send the code for examination if it's still relevant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured