Example usage for java.net DatagramSocket getBroadcast

List of usage examples for java.net DatagramSocket getBroadcast

Introduction

In this page you can find the example usage for java.net DatagramSocket getBroadcast.

Prototype

public synchronized boolean getBroadcast() throws SocketException 

Source Link

Document

Tests if SO_BROADCAST is enabled.

Usage

From source file:Main.java

public static void main(String args[]) {
    try {/*from w  w  w. j av a2 s  . c o  m*/

        InetAddress ia = InetAddress.getByName("www.java2s.com");

        DatagramSocket ds = new DatagramSocket();

        byte buffer[] = "hello".getBytes();
        DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, 80);

        // Send the datagram packet
        ds.send(dp);

        System.out.println(ds.getBroadcast());
    } catch (Exception e) {
        e.printStackTrace();
    }
}