0

To begin with - I'm not very familiar with socket and networking in general, however I have to use TCP sockets in my application.

I read data (13 bytes) from winapi TCP socket once a second. However, it's not often enough, data gets queued in the input buffer (is it correct term?) and the data I'm reading is not the last that came to the queue. I'd like to read the most recent 13 bytes. How to achieve that? To read data I'm using recv(mSocket,data,length,0);

Rames
  • 918
  • 11
  • 27
  • Why once a second? Why not read as fast as it arrives? – user207421 Sep 20 '15 at 10:18
  • @EJP well, yes, that's also a solution, however not always perfect - what if, for some reason, it arrives faster than I'm able to read it? – Rames Sep 20 '15 at 10:24
  • 2
    It's not 'also a solution'. It is *the* solution. Sleeping in network code is literally a waste of time. NB Data **can't** arrive faster than you can read it. TCP has flow control. – user207421 Sep 20 '15 at 10:30

0 Answers0