JAVA发送UDP数据

package Inter;

import java.io.IOException;
import java.net.*;

public class InetAddressDemo {
    public static void main(String[] args) throws IOException {
        //创建发送socket对象
        DatagramSocket ds = new DatagramSocket();
        byte[] bys = "哈哈哈".getBytes();
        DatagramPacket dp = new DatagramPacket(bys,bys.length, InetAddress.getByName("192.168.0.100"),10080);
        ds.send(dp);
        ds.close();
    }
}

 

posted @ 2022-04-13 22:50  phpwyl  阅读(130)  评论(0编辑  收藏  举报