编程语言
首页 > 编程语言> > JAVA发送UDP数据

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();
    }
}

 

标签:DatagramSocket,UDP,JAVA,bys,public,发送,import,java,ds
来源: https://www.cnblogs.com/phpwyl/p/16142553.html