?/TD>
Microsoft DirectX 9.0

NatPeer


The NATPeer sample allows the user behind a Network Address Translation (NAT) device to specify the address and optional password of an IDirectPlay8NATResolver server to be used for address resolution during calls to Host, EnumHosts, and Connect. For more information about NATs, see Network Address Translation, Firewalls, and Proxies.

Path

Source: (SDK root)\Samples\C++\DirectPlay\NatPeer

Executable: (SDK root)\Samples\C++\DirectPlay\Bin

User's Guide

When you start the program, a dialog box is displayed where you can specify connection information, including an option to enable NAT address resolution. If NAT address resolution is enabled, the Server Address and Password are used by Microsoft?DirectPlay?for resolving the external addresses of players behind NATs which are not Universal Plug and Play (UPnP) compatible. If the user chooses not to be the session host, a second dialog is displayed that allows users to find and connect to active sessions.

Once in a session, the game play is similar to SimplePeer.

Note  If you choose the Internetwork Packet Exchange (IPX) service provider and want to have DirectPlay perform a search for the address, select the use DPNSVR check box.

Programming Notes

If the NAT address resolution option is checked, the Server Address and Password fields are added as components of the local device address under the DPNA_KEY_NAT_RESOLVER and DPNA_KEY_NAT_RESOLVER_USER_STRING keys.

You can also specify multiple comma-delimited servers in the DPNA_KEY_NAT_RESOLVER component. Each server is tried simultaneously for speed, and the first response is used. If no server responds, the Host, Connect, or EnumHosts call still succeeds, but only local and UPnP connectivity information is used.

Because hosting these resolving servers require resources, you might want to prevent arbitrary players from using the server. This can be achieved with the DPNA_KEY_NAT_RESOLVER_USER_STRING address component. This value is passed directly to the resolving server for verification. The server can choose to respond as appropriate. Note that the user string is passed in clear text over the network, so if the text could contain sensitive information, you should encrypt it before sending.

For an implementation of an IDirectPlay8NATResolver server and more information about NAT address resolution, check the NATResolver sample included with the software development kit (SDK).



© 2002 Microsoft Corporation. All rights reserved.