I have a class that uses sockets to send and receive data asynchronously over the network:
class Client
{
private Socket mSocket;
/*
...
*/
public void SendPacket(byte[] data)
{
mSocket.BeginSend(data, 0, data.Length, SocketFlags.None, OnSent, null);
}
private void OnSent(IAsyncResult ar)
{
mSocket.EndSend(ar);
}
}
My question is, how can I calculate the upload rate, while the data is being sent? Does .Net have a way to indicate the download / upload rate over a specific socket?
I am using C# 4.0