Question

I've done some research on this, and I have seen some responses for limiting data transfer using a sleep. However my method of sending the image is via a buffered image over imageIO rather than a byte array etc.

DataInputStream in=new DataInputStream(client.getInputStream());

DataOutputStream out = new DataOutputStream(client.getOutputStream());

ImageIO.write(captureImg(),"JPG",client.getOutputStream());

Basically the program sends the captureImg over socket to a VPS. However I want to limit this transfer rate to something around 15kb/s. Is that possible with this method?

Thanks in advance!

Was it helpful?

Solution

I would write a wrapper for the OutputStream -> the write(...) methods.

Take a look at Guava's rate limiter, might come handy for solving that problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top