Click to See Complete Forum and Search --> : Problem with IOCP


Shvalb
May 10th, 2009, 01:23 PM
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.

DeniskaB
May 29th, 2009, 02:31 PM
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 :) ?

mikoil
May 30th, 2009, 09:23 AM
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.