Using the DirectPlay DPNSVR Application

DirectPlay

 
Microsoft DirectX 9.0 SDK Update (Summer 2003)

Using the DirectPlay DPNSVR Application


Microsoft® Windows® allows one process per Internet Protocol (IP) or Internetwork Packet Exchange (IPX) port. Windows does not allow multiple processes to share a single port. To act as a communication host, each application must use a separate port. This restriction creates several issues, especially when doing such tasks as enumerating running games.

  • Avoiding port conflicts. You must choose a port that does not conflict with other applications.
  • Managing multiple communications hosts on a single system. Each instance of a host must use a different port. Client applications then have to determine which port a particular host is using.
  • Avoiding ports that are already in use. If your preferred port is in use, your application must be able to use another port.

The DPNSVR application addresses these issues by acting as a forwarding service for enumeration requests. When an application begins hosting, it informs DPNSVR on which port it is running. DPNSVR listens on a well-known port and forwards any enumeration requests to all Microsoft DirectPlay® hosts on the system. Responses to enumeration requests contain the port number to which the host is actually connected.

The following diagram illustrates how DPNSVR, on a computer with two active host applications, handles an enumeration query from a remote client.

Diagram of how DPNSVR handles an enumeration query

DPNSVR offers developers the following advantages.

  • You can write generic enumeration routines that enumerate all the games running on a particular system.
  • You can use DirectPlay to select the host's port. Client applications can use the services of DPNSVR to enumerate the running games on a well-known port, and the responses will contain the port number to which the host is actually connected.
  • You need not allow for the situation where your application does not get the port it requests.
  • You need not be concerned about conflicts with other applications on the system

While most applications will want to use the services of DPNSVR, there are some circumstances where you may want to disable it. Two examples are:

  • You know what port you want to use, and only one instance of your application will be running on the computer.
  • You want to restrict the ability of players to enumerate your session. If you disable DPNSVR, only those players who know which port your host is connected to will be able to enumerate your host.

How to Use DPNSVR

To determine whether DPNSVR is supported by your service provider, call the GetSPCaps methods supported by the IDirectPlay8Peer, IDirectPlay8Client, or IDirectPlay8Server interface. If the service provider supports DPNSVR, the DPNSPCAPS_SUPPORTSDPNSRV flag will be set in the dwFlags member of the returned DPN_SP_CAPS structure. Only IP, IPX, and the network simulator service providers currently support DPNSVR.

Note  If you host a DPNSVR session with the network simulator service provider, you cannot host a DPNSVR session with the IP service provider and vice versa. All DPNSVR sessions must be with either the IP or the network simulator service provider. This does not affect your ability to host IPX session or sessions without DPNSVR.

Using DPNSVR requires no special effort, because it is selected by default. If you do not want enumeration requests forwarded to your host, you must explicitly disable DPNSVR by setting the DPNSESSION_NODPNSVR flag in the dwFlags member of the DPN_APPLICATION_DESC structure. Some additional characteristics of DPNSVR are:

  • DPNSVR does not have a window but it does appear in the user's task list.
  • If no applications are using DPNSVR, it shuts down after 30 seconds of inactivity. DPNSVR is automatically started up when an application begins hosting.
  • You can shut down DPNSVR by running DPNSVR /kill from the command line and it will shut down immediately. However, if you have any host applications open when you shut down DPNSVR, they will no longer be able to receive enumerations on the DPNSVR port.
Note  Applications can always enumerate your host if they know the port on which it is running, even if the DPNSESSION_NODPNSVR flag is set.

© 2003 Microsoft Corporation. All rights reserved.