WriteMulticast using the DatagramSocket.


DatagramSocket represents a socket for sending and receiving datagram packets.
A datagram socket is the sending or receiving point for a packet delivery service. Each packet sent or received on a datagram socket is individually addressed and routed. Multiple packets sent from one machine to another may be routed differently, and may arrive in any order.

The example below shows how a Multicast can be created using the DatagramSocket class.

byte[] outbuf = new byte[1024];
int port = 1234;
try {
    DatagramSocket socket = new DatagramSocket();
    InetAddress groupAddr = InetAddress.getByName("");
    DatagramPacket packet = new DatagramPacket(outbuf, outbuf.length, groupAddr, port);
} catch (SocketException e) {
} catch (IOException e) {


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.