Reputation: 2840
while (true) {
loc = getLocationOnScreen();
out.writeLong((long)loc.getX());
out.writeLong((long)loc.getY());
out.flush();
i++;
System.out.println(i);
}
This code will merrily go along for about 3 seconds, before it slows, then stops.
i
ends at about 16491
, never to continue increasing. What's going on here?
Upvotes: 0
Views: 284
Reputation: 13066
It is slowing down because , at the receiving end you might be doing long task using the value sent by you , before reading the next value. So the rate at which the other side is reading the data is smaller than the rate at which you are sending data to that. This keeps filling the receiving buffer at the other side and sending buffer at sender side. Eventually when both buffers are filled completely the transmission of data is halted.
Upvotes: 1