Measure the sending time of a datagram

Hello,

I would like to measure the sending time of a datagram on a machine, i.e. the time between the “socket.send(myPacket)” call and the moment where the last bit of the packet is pushed out of the machine to the network.

Is it a way in Java to do this ? ???

Thanks by advance.

Séb.

If you are only concerned about the server side its as simple as

long start = System.currentTimeMillis();
//do whatever
long duration = System.currentTimeMillis() - start;

Of course this can get into issues with the the granularity of the real time clock when you are measuring really small numbers.

It’s not what I mean to do…

Here’s an example : my machine has a 56kbits modem connection and I want to send a 2 Mbytes file. So I would like to measure the exact time to send this file. This time will be around 6-8 minutes. And I would like to have a way in Java to measure this time !
Your method doesn’t work, Coilcore, because the “socket.send” call is not blocking.

Séb.

Umm, sorry… As I said, “If you are only concerned about the server side”, I figured you were concerned about the efficency of your code, not the efficency of your hardware.

I can give you no insight into the efficiency of your hardware and would specullate that it would require some very indepth understanding of the particullar hardware (like details of how the drivers are buffering data, etc) - which Java generally avoids due to cross-platform questions.