Microsoft DirectX 8.1 (Visual Basic)

Selecting a Host for a Peer-to-Peer Session

Although most aspects of peer-to-peer games can be handled by the various users' communicating directly with each other, there are some tasks that must have a single owner. These tasks are handled by the game host. To join a session, you must know the address of the session's host. A common way to select a host is through a lobby server. In that case, when a user's application is connected to the session, the connection settings that you receive when Microsoft® DirectPlay® calls your DirectPlay8LobbyEvent.Connect method include the host's address object. To find out who the session host is:

You can also create a broadcast session, perhaps on a LAN subnet, by advertising yourself as a session host. To do so call DirectPlay8Peer.SetPeerInfo to set the player's name and then call DirectPlay8Peer.Host to advertise yourself as a potential host. You specify the configuration of the game by assigning values the DPN_APPLICATION_DESC type that is passed through the pdnAppDesc parameter of IDirectPlay8Peer.Host.

To allow your user to examine the available sessions and hosts, you can enumerate the available hosts by calling DirectPlay8Peer.EnumHosts. Once the user has selected a session, you can request a connection.