O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Send a Broadcast Message

Problem

You want to send a message to every user on the local subnet.

Solution

Use the UdpClient class with the appropriate broadcast address.

Discussion

Broadcasts are network messages that are forwarded to all the devices on a local subnet. When a broadcast message is received, the client decides whether to discard (depending on whether any application is monitoring the appropriate port). Broadcasts can’t travel beyond a subnet because routers block all broadcast messages. Otherwise, the network could be swamped in traffic.

To send a broadcast message, you use a broadcast IP address, which is the IP address that identifies the network and has all the host bits set to 1. For example, if the network is identified by the first ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required