|
Talk about the process:
When a datagram DatagramPacket is ready, it is sent using DatagramSocket.send ().
Problem occurred:
At this time, we need to start a timer. When the timer expires, we have not received the feedback from the datagram, then we can guess: the receiver did not receive the datagram we sent. Then we will automatically resend a datagram.
The question is how to implement this timer.
If you use the Timer class to implement, then the run () method rewritten in TimerTask must be static code (this should be the case), then there is no way to resend this DatagramPacket, because it is not final.
Excuse me, heroes, how to solve this problem? |
|