if (ret == 0)
break;
+ bytes_received += ret;
+
// update the central counter after every 1MB (8ms
// at gigabit speeds, should be enough) of received data
if (bytes_received > 1048576) {
pthread_mutex_lock(&receive_mutex);
- total_bytes_sent += bytes_received;
+ total_bytes_received += bytes_received;
pthread_mutex_unlock(&receive_mutex);
bytes_received = 0;
}
}
- sleep(3600);
+ // Just stay around collecting statistics until we're done.
+ for ( ;; ) {
+ unsigned long long sent, received;
+
+ pthread_mutex_lock(&send_mutex);
+ sent = total_bytes_sent;
+ pthread_mutex_unlock(&send_mutex);
+
+ pthread_mutex_lock(&receive_mutex);
+ received = total_bytes_received;
+ pthread_mutex_unlock(&receive_mutex);
+
+ printf("%llu %llu\n", sent, received);
+
+ sleep(1);
+ }
exit(0);
}