O'Reilly logo

Microsoft XNA 4.0 Game Development Cookbook by Luke Drumm

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

Connecting across a LAN

If you're interested in writing games that can operate across a LAN, then there's a very good chance that you'll be interested in some sort of broadcast messaging service to initially allow clients to discover each other, and possibly for fast peer-to-peer game play.

This example demonstrates how to send and receive broadcast messages between both clients on local, as well as remote, machines.

Getting ready

This example requires a SpriteFont file with the asset name of Text to be present in your solution. As it's purely for debugging purposes, any typeface and size will do.

How to do it...

To start broadcasting across the network yourself:

  1. Add a class named BroadcastClient to the solution:
    class BroadcastClient
    {
    
  2. Insert the ...

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