Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有使用阻塞套接字通过调用recv 接收数据的代码。一切正常。但是,无法向用户报告过程中任何时候下载的字节数。我假设为了能够做到这一点,我需要多次调用recv,并在每次调用后报告?还是有更好、更有效的方法来做到这一点?
根据MSDN,recv执行以下操作:
recv
recv 返回接收到的字节数,buf 参数指向的缓冲区将包含接收到的数据。
因此,您可以创建一个int received并累积接收到的字节,recv直到recv不再接收,然后报告received变量中累积的总数。
int received
received