发送数据报
import java.io.IOException; import java.net.DatagramPacket;/** 来自 时代Java公众号 - nowjava.com**/ import java.net.DatagramSocket; import java.net.InetAddress; import java.net.SocketException; public class Main { public static void send(InetAddress dst, int port, byte[] outbuf, int len) { try { DatagramPacket request = new DatagramPacket(outbuf, len, dst, port); DatagramSocket socket = new DatagramSocket(); socket.send(request);