Socket.EnableBroadcast Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a Boolean value that specifies whether the Socket can send or receive broadcast packets.

Namespace: System.Net.Sockets
Assembly: System (in system.dll)

public bool EnableBroadcast { get; set; }
/** @property */
public boolean get_EnableBroadcast ()

/** @property */
public void set_EnableBroadcast (boolean value)

public function get EnableBroadcast () : boolean

public function set EnableBroadcast (value : boolean)

Property Value

true if the Socket allows broadcast packets; otherwise, false. The default is false.

Exception typeCondition


This option is valid for a datagram socket only.


The Socket has been closed.

Broadcasting is limited to a specific subnet, and must use User Datagram Protocol (UDP.) For Internet Protocol version 4, you can broadcast to your local subnet by sending a packet to; or you can use the directed broadcast address, which is the network portion of an Internet Protocol (IP) address with all bits set in the host portion. For example, if your IP address is (a Class C address, with a netmask of -- the network portion is the first three octets, and the host portion is the last octet), your directed broadcast address is

Setting this property on a Transmission Control Protocol (TCP) socket will have no effect.

The following code example demonstrates the use of the EnableBroadcast property.

static void ConfigureUdpSocket(Socket udpSocket)
    // set the Don't Fragment flag.
    udpSocket.DontFragment = true;
    // Enable broadcast.
    udpSocket.EnableBroadcast = true;

    // Disable multicast loopback.
    udpSocket.MulticastLoopback = false;

    Console.WriteLine("Udp Socket configured:");
    Console.WriteLine("  DontFragment {0}", 
    Console.WriteLine("  EnableBroadcast {0}", 
    Console.WriteLine("  MulticastLoopback {0}", 

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions