Chat software project UDP upgrade version

Source: Internet
Author: User

1 Importjava.net.*;2 ImportJava.io.*;3 classUdpSend24 {5      Public Static voidMain (string[] args)throwsException6     {7Datagramsocket ds =NewDatagramsocket ();8BufferedReader BUFR =NewBufferedReader (NewInputStreamReader (system.in));9String line =NULL;Ten          while((Line=bufr.readline ())! =NULL) One         { A             if("886". Equals (line)) -                  Break; -             byte[] buf =line.getbytes (); theDatagrampacket DP = -         NewDatagrampacket (Buf,buf.length,inetaddress.getbyname ("192.168.1.255"), 10001); - Ds.send (DP); -         } + ds.close (); -     } + } A classUdpRece2 at { -      Public Static voidMain (string[] args)throwsException -     { -Datagramsocket ds =NewDatagramsocket (10001); -          while(true) -         { in             byte[] buf =New byte[1024]; -Datagrampacket DP =NewDatagrampacket (buf,buf.length); to Ds.receive (DP); +String IP =dp.getaddress (). gethostaddress (); -String data =NewString (Dp.getdata (), 0, Dp.getlength ()); theSystem.out.println (ip+ "::" +data); *         } $     }Panax Notoginseng}

Chat software project UDP upgrade version

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.