Reputation: 996
I have code that uses a blocking socket to receive data via a call to recv. Everything works just fine. However there is no way to report to the user the number of bytes downloaded at any point in the process. I'm assuming that to be able to do this I would need to make multiple calls to recv, and report after each call? Or is there a better, more efficient way to do this?
Upvotes: 0
Views: 434
Reputation: 63220
per MSDN, recv
does the following:
recv returns the number of bytes received and the buffer pointed to by the buf parameter will contain this data received.
So you could create an int received
and accumulate the bytes received that are returned by recv
until recv
there is no more to receive, then report the total accumulated in your received
variable.
Upvotes: 1