|Microsoft DirectX 9.0|
Source: (SDK root)\Samples\C++\DirectPlay\NatPeer
Executable: (SDK root)\Samples\C++\DirectPlay\Bin
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.
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).