I have a requirement where i need to test the time required to send a few bytes. But instead of writing a socket program and jumping into the complexities , i just want to dump the byte 'into the dark' without caring for whether the connection is made or the byte is received. My sole aim is to measure the time taken for the program to send those many bytes. What could be the best way to achieve something like this?
1 Answer
UDP should do what you want. You can use DatagramSocket for it in Java.
UDP is a network protocol that doesn't establish a connection before sending data, and doesn't have any (built-in) way to make sure the other side received it.
2 Comments
phoenix
so u mean that i do not have to write a client program then. I just want to save myself from the hassle of writing a client program.
Brendan Long
@phoenix UDP doesn't care if there's anything on the other side of the connection, so it should work how you want. M.M. makes a good point though -- if you're just throwing the data away, you might as well just write it to a file instead. Or you could just throw the data away, since all you care about is how long it takes to generate it?