background image

  String hello = "Hello, I am come in!";
  //要发送的数据

  byte[] buf = hello.getBytes();
  //将数据转换成 Byte 类型

  op = new DatagramPacket(buf, buf.length, target, 12345);
  //将 BUF 缓冲区中的数据打包

  ds.send(op);
  //发送数据

  ds.close();
  //关闭连接