使用IdTCPServer的疑问。 ( 积分: 100 )

  • 主题发起人 主题发起人 xounter
  • 开始时间 开始时间
X

xounter

Unregistered / Unconfirmed
GUEST, unregistred user!
我最近拿IdTCP控件作了个自动更新程序,我想问点事情关于IdTCPServer
我的客户机使用IdTCPclient进行通信,通信内容为10-20字节,然后断开使用ftp进行取文件更新。
我想问下我使用IdTCPServer可以同时接受多少客户机的连接而不会挂掉?我这里大概有900-1q个客户机需要连接,我觉得极端情况下会有100个连上来。(程序是开机自启动和手工运行两种方式,不一定同时开机)这样IdTCPServer能撑住么?
有用过的朋友么?请指点下,谢谢啦。
 
呵呵,ls兄弟,能给分析下么?
我应该如何进行服务器端程序编写呢?
我现在啥都没用直接用的系统的东西,我现在对线程啥都不太明白。
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
lread,lwrt: string;
begin
lread:=Trim(AContext.Connection.IOHandler.ReadLn);
writememo(AContext.Connection.Socket.Binding.PeerIP+'<>接受其发送的数据是:'+lread);
if True then
begin
lwrt:=checksver(lread);
writememo(lwrt);
// lwrt:='123|13|ctb2426.exe';
AContext.Connection.IOHandler.WriteLn(lwrt);
end;
end;
这是我的代码,请问这样行么?
 
咳咳,各位领导给看看行不?
 
Indy官方早就解释过这个问题了,原文如下:
Hundreds of Threads


With a busy server hundreds or even thousands of threads can easily be needed. There is a common misconception that hundreds of threads will instantly kill your system. This is a false belief.

With most servers threads spend most of their time waiting on data. While waiting on blocking calls the thread will be inactive. Thus in a server with 500 threads only 50 may be active at a single time.

The number of threads that your system has running now may surprise you. With only minimal services started and the following applications running:



My system has 333 threads currently created:



Even with 333 threads you can see that my CPU utilization is only at 1%. A heavily used IIS (Microsoft Internet Information Server) will create hundreds or thousands more threads.


连接地址:
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&amp;frmfile=index.html
点击左边的Introduction to Indy可阅读更多内容.
 
另外,Indy提供了连接池对象IdSchedulerOfThreadPool(Indy9里面好像叫IdSchedulerOfThreadMgr),将它和你的IdTCPServer的属性关联就可减少因为线程创建和销毁所产生的系统负荷.

更多内容参看帮助.
 
后退
顶部