Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use socket to do Game Development

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to use socket to do game development". In daily operation, I believe many people have doubts about how to use socket to do game development. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to use socket to do game development". Next, please follow the editor to study!

The three softwares are foreground server (qt), background server (win32) and customer service side (cocos2dx). The database of the background server adopts sqlite3 (it is convenient to integrate the database into the background server) and the blocking TCP protocol (using the waiting event function WSAWaitForMultipleEvents). With regard to the external network connection of the customer service end, I use the peanut shell internal network to penetrate the hardware to achieve.

Project performance:

In the server development process, the ① client uses ODSocket cross-platform sockets. Considering the multi-concurrency problem of the server, I used two-day message queues (sending message queues and receiving message queues). Each message contains customer server sockets and data packets. Taking into account the problem of excessive packet loss, ② needs to unpack and send the sent data packet, and design the packet structure [header, unpacking code ID, unpacking number, package body, packet tail]. If it detects the unpacking code ID, it indicates that the packet is subpackaged. If it detects that the unpacking number is 0, it will put it into the package container, and detect whether the packet can be closed from the container to be processed. If the number is not continuous or there is no ID code in the package container, it is possible to close the packet. Put it into the pending subcontract container. Until the tail special characters are detected, complete the package and put it into the receiving message queue ③ database archive, save all the game data every 5 minutes ④ when the game account login to read the role data from the database to the memory ⑤ foreground server only provides other logical servers to communicate with each other to facilitate the later implementation of cross-service competition customer server development process ① completed the customer server chat function Mainly every chat data of players, including facial expressions, items information, etc., need to pay attention to aesthetic ② to complete the role navigation path, considering that other players' actions can also be seen by themselves, need to forward the coordinates of other players through the server ③ players need to display team information after forming a team, and team status display ④ NPC dialogue ⑤ pet data archive And the customer server reads the ⑥ mount display ⑦ combat logic ⑧ local data solidification

At this point, the study on "how to use socket to do game development" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report