A large number of network functions of online games is on Winsock / Socket. But Microsoft's game development kit DirectX SDK also provides the network functionality ---- DirectPlay.
Of course, Winsock / Socket compared to DirectPlay, there is extensive advantages.
This "excellent" and "lack" are not one or two sentences can be summarized (this paper is not the difference between them).
DirectPlay Advantages: Microsoft engineers have written its network function, so you can save you a lot of bubble MM times. For example, network initialization, network communication function, network packet function, etc. (" Network group "is the center of this article)
DirectPlay Disadvantages: His server can only run on a Windows platform; only support a small number of players (no company or personal prove, I have asked questions in the MSDN forum, but Microsoft said This is mainly related to the type of procedure you write and your server and they have done a test of 10,000 players in the past. I see: I am in Microsoft Post. See:
http://communities.microsoft.com/newsgroups/previewFrame.asp?ICP=msdn&sLCID=us&sgroupURL=microsoft.public.win32.programmer.directx.networking&sMessageID=%3CObG98IsTCHA.1640@tkmsftngp10%3E)
Radish green dishes have love, with anyone who will leave it to discuss it.
Ok, now enter the theme.
First introduce you to the "group" in DirectPlay.
We know that in the network, you must send a message to someone, you must know his address, that is ? Fortunately, DirectPlay introduced the concept of group. As long as you add these people to a group, then give this group, each of them will receive this message. How? Very cool, is it ~~
Cool is cool, but the problem is coming, DirectX SDK 8.1 has a considerable change in DirectX SDK 7.0, and these changes in the SDK Help are just a few sentences (some don't even speak). For example, there are several functions It disappeared in 8.1, such as: addgrouptogroup (), RemoveGroupFromGroup (), CreateGroupingRoup (), createplayer (), etc. ...
And what should we do when we use these functions? SDK`s HELP is not clear ~~
And the existing function is just what is the type of this function. What is the parameter, the return value is, but there is no specific usage ...
All everything will show you one by one in this article, and the code in the example has a detailed Chinese annotation.
Note:
This example is passed in the following compilation environment: VC6.0, DirectX 8.1 SDK, WinXP
Finish
annex:
Description: This example download Engine2.zip