摘要
多人网络游戏中协议是很重要的保证,通过对网络协议的比较发现:TCP协议能够保证数据包的完整、有序地传送,但传送数据包的速度比较慢;而UDP传送数据包的速度远远快于TCP协议,但是不保证数据包的传送和有序。为此,文中讨论了选择TCP/IP的理由,以及为克服TCP协议传送速度慢而采取的一些方法,诸如用W insock函数族来开发客户端,采用更高效的重叠I/O模型;并在服务器端做详细的设置,比如对服务器的网络连接做设置,对消息做设置,特别阐述了使用服务器广播技术,把游戏地图分成九块广播出去,并采用二维矩阵碰撞检测的方法,把相交块的坐标转换成内部坐标,然后进行运算,算出块之间的相对位置,并着重给出了同步问题的解决方案,最后阐述了综合同步法的设计思路;文中还根据论述内容画出了关于"客户端非重要消息的处理流程"图和"客户端重要消息的处理流程"图,使读者一目了然。
Protocol is a very important guarantee in multiplayer online games. It was found that TCP could transmit data packets integrally and orderly, but its speed was slow; on the other hand, UDP could transmit data packets faster, but the integrality and order of data packets could not be guaranteed. To solve this problem, a proposal using TCP/IP was put forward, and some methods to raise its transmission speed were given. We can use Winsock function group to develop the clients with high -efficient overlapped I/O model. In the mean time, network connections, messages, etc. in the server are set in detail. Particularly, by broadcasting technology in server, the map is divided into nine game blocks and broadcast. two - dimensional matrix collision detection methods, the intersection coordinates can be turned into internal ones and the relative position of the blocks can be calculated. The solution of synchronization is also given. Processing flow charts for both critical and non - critical messages at clients are also described.
出处
《辽东学院学报(自然科学版)》
CAS
2009年第1期47-51,共5页
Journal of Eastern Liaoning University:Natural Science Edition