Platform SDK: DirectX

TCP/IP

The Transmission Control Protocol/Internet Protocol (TCP/IP) service provider uses Windows Sockets to communicate over the Internet or local area network (LAN) using the TCP/IP protocol. It uses User Datagram Protocol (UDP) packets for nonguaranteed messaging and TCP for guaranteed messaging. A single computer can host multiple DirectPlay sessions using TCP/IP.

When the application enumerates sessions, TCP/IP displays a dialog box asking the user for the session's IP address. If the session is on the Internet, the user must enter the IP address of the computer hosting the session to be joined. If the computer has a name (such as microsoft.com), the name can be used instead of the IP address, and DirectPlay will use Domain Name System (DNS) lookup to find it. The user can also leave the address blank and select OK. In this case, DirectPlay will broadcast a message looking for sessions. This will generally work only on a LAN and only on the same subnet.

[C++]

If you're hosting a session, the application can use IDirectPlay4::GetPlayerAddress to obtain the local IP address.

An application can use the IDirectPlay4::InitializeConnection method, or the IDirectPlayLobby3::SetConnectionSettings method followed by a call to IDirectPlayLobby3::Connect, to supply an IP address to the service provider in a DirectPlay address. The IP address must be a null-terminated ANSI or Unicode string (each has a different data type GUID). If a broadcast enumeration of sessions is desired, the address must be a zero-length string—that is, a string consisting only of the null terminator. For more information, see DirectPlay Address.

The TCP/IP service provider uses port 47624 to send and receive enumeration requests. Communications are sent on the port range 2300-2400. To work through a firewall, all computers must be using DirectX 6.0 or later and port 47624, and the range 2300-2400 must be open for both inbound and outbound TCP and UDP traffic. For more information, see Firewall Support.

Note  DirectPlay starts assigning ports at 2300 and works its way up, sequentially. It is possible to open a smaller range starting at 2300.

An application can select a specific port to use. To do so, it must initialize the TCP/IP service provider with a DirectPlay address that includes the data chunk DPAID_INetPort. For more information, see DirectPlay Address and DirectPlay Address Data Types. If an application selects a specific port to use, all communication is sent through that port, and it is only necessary to open that one port (for both inbound and outbound using TCP and UDP).

The TCP/IP service provider GUID is defined as DPSPGUID_TCPIP.

[Visual Basic]

If you're hosting a session, the application can use DirectPlay4.GetPlayerAddress to obtain the local IP address.

An application can create a DirectPlay address for an IP address by using the DirectPlayLobby3.CreateINetAddress method. The address can then be supplied to the service provider by passing the DirectPlayAddress object to DirectPlay4.InitializeConnection method, or by passing it to DirectPlayLobby3.SetConnectionSettings and then calling DirectPlayLobby3.Connect. For more information, see DirectPlay Address.

Adding DirectPlay lobby support can eliminate the need for users to enter an IP address when the game is started. For more information, see Synchronized Launching.