Question : CSocket send and receive

can someone explain how this works?

here is my problem.

I want to receive 10k over a socket, maybe multiple times, but after each time I receive one I would send back another command to get the next.

the problem is that  when I CSocket::Receive it doesn't seem to wait, so then I use something like this

while(x<10000)
      {
      x+=m_PopServer.Receive(buf,512);
                stor+=buf
                }


but it doesn't work either, I get just the first 512 maybe...
then I introduce sleep(500) in the loop to slow it down and it works on some computers and not others.

how do you wait for the socket to send stuff to you properly...I thought the whole point of using CSocket vs async socket was to avoid loosing data like this?

Thanks for your help,

Bob

Answer : CSocket send and receive

1. you need to make sure the socket is blocking
2. you need to make sure you initialize x to 0 before the while loop


do you have some sample workspaces?

Random Solutions  
 
programming4us programming4us