Network engine is an important part of the online game server, the communication between server and client is based on the network engine. The performance of the online game server is depends on the performance of the network engine. The paper is research into how to build a high-performance network engine.There are about three main functions in the network engine: receiving and sending the data, compressing and uncompressing the data and encrypting and decrypting the data. In the paper, receiving and sending data, encrypting and decrypting data are carried out a detailed analysis and research.Receiving and sending data is the most basic and the most important function of the network engine. The paper compares with several commonly used techniques in linux platform, and analyses the process of receiving and sending data with TCP/IP protocol, then designs a solution which is stable and efficient in receiving and sending data by the compares and the analysis. In addition, the paper carries out a detailed analysis with some of the important aspects of the solution, and uses some optimization techniques in the solution, such as memory pool, circular buffer, etc. With the popularity of multi-core server, in order to take full advantage of CPU resources, and improve the performance of the network engine, the paper carries out an analysis and design for using the multi-threading mechanism in the network engine.The function of encrypting and decrypting data in network engine is used for ensuring the security of the online game. On the one hand it protects the data be decrypted by the third-party, on the other hand it makes making an anti-plug more difficult. The paper carries out an analysis and research with the function of encrypting and decrypting data in online game, and designs a solution of encrypting and decrypting data for the online game. |