1 Try {2 //send data to the specified IP and port ~ ~ 3 //let's explain who sent the data! 4 byte[] IP =inetaddress.getlocalhost (). Gethostaddress (). GetBytes ();5DP =Newdatagrampacket (IP, ip.length, Sendiad, Qqreceive.getport ());6 Ds.send (DP);7 8 //this is mainly due to the fact that multiple datagram packets are sent when the packet is dropped ... So pause for a while! 9 Try {TenThread.Sleep (100); One}Catch(interruptedexception E1) { A } - -DP =NewDatagrampacket ("PARAGRAPH". GetBytes (), "PARAGRAPH". GetBytes (). Length, Sendiad, Qqreceive.getport ()); the Ds.send (DP); - - Try { -Thread.Sleep (100); +}Catch(interruptedexception E1) { - + } A atDP =NewDatagrampacket (BT, Bt.length, Sendiad, Qqreceive.getport ()); - Ds.send (DP); -}Catch(IOException E1) { - e1.printstacktrace (); -}
Datagramsocket solution for packet loss in Java when multiple datagram packets are sent continuously