A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 周怡 中级黑马   /  2013-2-5 20:32  /  1376 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. import java.net.*;
  2. import java.io.*;
  3. class  UdpSend2
  4. {
  5.         public static void main(String[] args) throws Exception
  6.         {
  7.                 DatagramSocket ds = new DatagramSocket();

  8.                 BufferedReader bufr =
  9.                         new BufferedReader(new InputStreamReader(System.in));

  10.                 String line = null;

  11.                 while((line=bufr.readLine())!=null)
  12.                 {
  13.                         if("886".equals(line))  //886是什么意识啊  
  14.                                 break;

  15.                         byte[] buf = line.getBytes();

  16.                         DatagramPacket dp =
  17.                                 new DatagramPacket(buf,buf.length,InetAddress.getByName("192.168.1.255"),10001);

  18.                         ds.send(dp);
  19.                 }
  20.                 ds.close();
  21.         }
  22. }
复制代码

4 个回复

倒序浏览
您需要登录后才可以回帖 登录 | 加入黑马