Datagramsocket solution for packet loss in Java when multiple datagram packets are sent continuously

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.