class UdpSend {
public static void main(String[] args) throws Exception
{
DatagramSocket ds=new DatagramSocket();
DategramPacket(byte[]buf,int length,InetAddress address,int port)
byte []buf="udp ge men laile ".getBytes();
DatagramPacket dp= new DatagramPacket(buf,buf.length,InetAddress.getByName("192.168.1.254"),10000);//getByName("192.168.1.254"),这里不是在给定主机名的情况下确定主机的 IP 地址吗,怎么输ip地址了啊求解啊 ds.send(dp);
ds.close();
}
} |
|