游戏开发论坛

 找回密码
 立即注册
搜索
楼主: tfisher

2000以上并发用户的游戏服务器框架

[复制链接]

25

主题

304

帖子

311

积分

中级会员

Rank: 3Rank: 3

积分
311
发表于 2003-12-30 11:33:00 | 显示全部楼层

恩,

完成端口也不用总是LOCK也,
具体看怎么用的说,只要发出请求的BUF不去动他,就可以了.
我使用发送队列就是防止LOCK的,因为线程临界区是发送队列,逻辑处理线程只要不断的向队列添加数据就可以了
完成端口的工作线程则不断的从队列中取出数据,然后发出发送请求.
请求的数量是可以设置的,为此,要为每个请求开一个WSABUF,一个BUF,一个OVERLAPPED.
选择使用完成端口,也是因为完成端口有个很方便的功能就是,完成通知里面可以存储一些关联信息,以便知道是哪个连接,或者哪个角色的完成事件,扩展一下还能知道是哪个连接的哪个请求的完成信号.
这个比SELECT强大很多的.


FF:


CONNECTION[X]
{
WSABUF REQ[N];
BUFFER  BUFS[N];
OVERLAPPED_MY OLREQ[N];
VOID ONCOMPLETED(REQID)
{
REMOVEFROMQUEUE(REGID)
BEGINREQ(REGID,DATA)
}
VOID BEGINREQ(REQID,DATA)
{
WSASEND/RECV()...
ADDTOQUEUE(REGID)
}
}

28

主题

685

帖子

703

积分

高级会员

Rank: 4

积分
703
发表于 2003-12-30 11:45:00 | 显示全部楼层

Re:2000以上并发用户的游戏服务器框架

我用完成端口的时候没有发送队列。不过那时候小包不多。
因为OVERLAPPED是每次发送和接收用的,我就把BUFFER直接做到了OVERLAPPED里面去了。
class  CBuffer : public OVERLAPPED
{
    int type;
   char buf[BUF_SIZE];
  WSABUF m_wsabuf;
}
type就是相当于包的事件类型。
我把CONNECTION指针放在了一开始的CREATEIOCP里面,这样getiocpstatus正好能收到CONNECTION的指针和CBUFFER的指针。
从CBUFFER的指针可以得到是发送完毕还是接收完毕或者是其他的事件类型。

不过这样还是要LOCK的呀?因为发送线程中这个CONNECTION可能在中途退出被删,不然对这个CONNECTION也要加个引用计数了。每次插入广播包的时候检查一下是否已退出?
有QQ吗?我的43791167,有机会请教一下。

25

主题

304

帖子

311

积分

中级会员

Rank: 3Rank: 3

积分
311
发表于 2003-12-30 12:06:00 | 显示全部楼层

CONNECTION的ONDISCONNECT

里面会等待所有的请求队列的数据元素的值减少到0
,另外,现在我的做法是,有一个CONNECTION回收机制,不是DELETE它,而是回收到未使用状态,在这个回收的过程中,CONNECTION会有个时期是短暂等待.
这样,整个CONNECTION的数量和安全性会得到保证.
并且,所有的CONNECTION都有个UPDATE,可以对自己的状态进行控制.

0

主题

48

帖子

50

积分

注册会员

Rank: 2

积分
50
发表于 2003-12-30 13:50:00 | 显示全部楼层

Re:2000以上并发用户的游戏服务器框架

用tcp/ip???
我是用udp
现在大部分游戏都是udp的

25

主题

304

帖子

311

积分

中级会员

Rank: 3Rank: 3

积分
311
发表于 2003-12-30 14:44:00 | 显示全部楼层

啊???

是吗??

8

主题

38

帖子

90

积分

注册会员

Rank: 2

积分
90
QQ
发表于 2003-12-30 15:48:00 | 显示全部楼层

Re: Re:2000以上并发用户的游戏服务器框架

路过看贴! 顶~
eqinzm: Re:2000以上并发用户的游戏服务器框架

用tcp/ip???
我是用udp
现在大部分游戏都是udp的


好象TCP/IP多吧

0

主题

48

帖子

50

积分

注册会员

Rank: 2

积分
50
发表于 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.

2

主题

13

帖子

13

积分

新手上路

Rank: 1

积分
13
发表于 2003-12-30 16:49:00 | 显示全部楼层

Re:2000以上并发用户的游戏服务器框架

传奇世界每组9台,每组承担人数最大3500人~!我有传奇世界,传奇3的服务器设备清单(西北),还有传世的网络拓扑,谁要?

28

主题

685

帖子

703

积分

高级会员

Rank: 4

积分
703
发表于 2003-12-30 16:55:00 | 显示全部楼层

Re:2000以上并发用户的游戏服务器框架


能介绍一下是什么游戏吗?什么类型的?

/===========
--------------------------------------------------------------------------------

Re:2000以上并发用户的游戏服务器框架

用tcp/ip???
我是用udp
现在大部分游戏都是udp的





0

主题

48

帖子

50

积分

注册会员

Rank: 2

积分
50
发表于 2003-12-30 17:18:00 | 显示全部楼层

Re:2000以上并发用户的游戏服务器框架

RPG+对战
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-23 03:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表