what library are you using? if it doesnt have a built in function i would write a timer and transfer for like 10 seconds. then divide the number of packets sent by 10 and the number recieved by 10. youll get the average speed per second. there is probably a more elegant solution but i cant think of one.
I`m using POSIX library,
My C++ server connects to Android socket, i want to measure transfer rate when i`m sending and receiving some information to get internet speed of Android device.