|
|
发表于 2003-12-30 16:42:00
|
显示全部楼层
Re:2000以上并发用户的游戏服务器框架
国外一个论坛的帖子:
most MMORPG's use UDP for lag and bandwidth issues, while FPS's, which generally have more bandwidth per player, is more dependant on accuracy, and have servers close to the players, can get away with TCP.
Don't know anything about PS's network code :p
TCP, generally speaking, is unsuitable for games, unless they are low bandwidth (like turn based games, such as chess). The reason being that TCP is guaranteed delivery and ordering, which on paper sounds like a great idea, but in practice causes many problems. If you start losing packets in a TCP system, because of the ordering, you actually cease all delivery until the next packet gets through. In fact, TCP will actually give up resending the packet after a while and will start sending small "test" packets to try to establish a path again. Once it gets the path back, only then will it try to resend the errant packet.
What it all comes down to is that TCP can actually lag by *minutes* at a time (occassionally), and it is not uncommon for it to lag by many seconds. For real time game use, this is unacceptable.
Therefore, most real time games use UDP with thier own reliability and ordering system on top of it. You may think this is re-inventing the wheel, but actually it is not. With UDP and your own system, you can selectively determine which packets need to be ordered and/or reliable.
I've not looked at the PS code, but in my game, for instance, chat packets are neither ordered nor reliable. Item packets are reliable, but not ordered. Movement packets are both ordered and reliable. This means I can send chat data at any point without getting held up by a stray Item packet or movement packet like I would with TCP. I imagine PS uses a similar selective system.
|
|