Source Code : Create DatagramPacket from byte array
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Create DatagramPacket from byte array
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
class Main {
public static void main(String args[]) throws Exception {
InetAddress ia = InetAddress.getByName(args[0]);
int port = Integer.parseInt(args[1]);
DatagramSocket ds = new DatagramSocket();
while (true) {
String s = "asdf";
byte buffer[] = s.getBytes();
DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, port);
ds.send(dp);
}
}
}
Thank with us