Export (0) Print
Expand All

UdpClient.EnableBroadcast Property

Gets or sets a Boolean value that specifies whether the UdpClient may send or receive broadcast packets.

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

public bool EnableBroadcast { get; set; }

Property Value

Type: System.Boolean
true if the UdpClient allows broadcast packets; otherwise, false. The default is false.

Broadcasting is limited to a specific subnet. You can broadcast to your local subnet by sending a packet to 255.255.255.255; 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 192.168.1.40 (a Class C address, with the network portion as the first three octets, and the host portion is the last octet), your directed broadcast address is 192.168.1.255.

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

public static void GetSetEnableBroadcast(UdpClient u)
{
    // Set the Broadcast flag for this client.
    u.EnableBroadcast = true;
    Console.WriteLine("EnableBroadcast value is {0}",
        u.EnableBroadcast);
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft