请教高手TCP连接数限制
我发现在同时连接100个左右以后的连接就连不上了。究竟是那方面的问题呢?
测试代码:3个文件
=============================
Unit3.pas
============================
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, WSOcket, ComCtrls, StdCtrls;
type
TForm3 = class(TForm)
ListView1: TListView;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure COnnected(Sender: TObject; error: Word);
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
var
Clients: array of TWSocket;
procedure TForm3.COnnected(Sender: TObject; error: Word);
var
li: tlistitem;
begin
li := listView1.FindData(0, Sender, True, True);
if assigned(Li) then
begin
if error <> 0 then
begin
li.SubItems[0] := 'fail:' + Inttostr(error);
end
else
li.subitems[0] := 'ok:';
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
var
I: Integer;
W: twsocket;
begin
for I := 0 to listview1.items.count - 1 do
begin
Clients[I].Addr := listView1.Items[I].Caption;
Clients[I].Port := '7000';
Clients[I].OnSessionConnected := Connected;
Clients[i].Connect;
end;
end;
procedure TForm3.FormCreate(Sender: TObject);
var
Strings: TStrings;
I: Integer;
li: tlistitem;
begin
strings := tstringlist.Create;
strings.LoadFromFile(GetCurrentDir + '\ip.txt');
setlength(clients, strings.count);
for I := 0 to strings.Count - 1 do
begin
Clients[I] := TWSocket.Create(nil);
li := listView1.Items.Add;
li.Caption := strings[i];
li.Data := clients[I];
li.SubItems.Add('');
end;
strings.Free;
end;
end.
======================================
Unit3.dfm
======================================
object Form3: TForm3
Left = 0
Top = 0
Caption = 'Form3'
ClientHeight = 238
ClientWidth = 337
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object ListView1: TListView
Left = 0
Top = 0
Width = 337
Height = 238
Align = alClient
Columns = <
item
Caption = 'ip'
Width = 120
end
item
Caption = #29366#24577
end>
TabOrder = 0
ViewStyle = vsReport
end
object Button1: TButton
Left = 200
Top = 72
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
end
测试代码:3个文件
=============================
Unit3.pas
============================
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, WSOcket, ComCtrls, StdCtrls;
type
TForm3 = class(TForm)
ListView1: TListView;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure COnnected(Sender: TObject; error: Word);
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
var
Clients: array of TWSocket;
procedure TForm3.COnnected(Sender: TObject; error: Word);
var
li: tlistitem;
begin
li := listView1.FindData(0, Sender, True, True);
if assigned(Li) then
begin
if error <> 0 then
begin
li.SubItems[0] := 'fail:' + Inttostr(error);
end
else
li.subitems[0] := 'ok:';
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
var
I: Integer;
W: twsocket;
begin
for I := 0 to listview1.items.count - 1 do
begin
Clients[I].Addr := listView1.Items[I].Caption;
Clients[I].Port := '7000';
Clients[I].OnSessionConnected := Connected;
Clients[i].Connect;
end;
end;
procedure TForm3.FormCreate(Sender: TObject);
var
Strings: TStrings;
I: Integer;
li: tlistitem;
begin
strings := tstringlist.Create;
strings.LoadFromFile(GetCurrentDir + '\ip.txt');
setlength(clients, strings.count);
for I := 0 to strings.Count - 1 do
begin
Clients[I] := TWSocket.Create(nil);
li := listView1.Items.Add;
li.Caption := strings[i];
li.Data := clients[I];
li.SubItems.Add('');
end;
strings.Free;
end;
end.
======================================
Unit3.dfm
======================================
object Form3: TForm3
Left = 0
Top = 0
Caption = 'Form3'
ClientHeight = 238
ClientWidth = 337
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object ListView1: TListView
Left = 0
Top = 0
Width = 337
Height = 238
Align = alClient
Columns = <
item
Caption = 'ip'
Width = 120
end
item
Caption = #29366#24577
end>
TabOrder = 0
ViewStyle = vsReport
end
object Button1: TButton
Left = 200
Top = 72
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
end
...全文
相关推荐
破解TCP连接数限制
在互联网通信中,TCP(传输控制协议)是广泛使用的面向连接的、可靠的传输协议。TCP连接数限制是指操作系统为了防止过多的并发连接消耗系统资源,通常会设定一个上限,限制同一时间可以建立的TCP连接数量。
禁用Win7的TCP半开连接数限制.txt
禁用Win7的TCP半开连接数限制.txt禁用Win7的TCP半开连接数限制.txt
P2P软件Windows操作系统最大半开连接数(TCP限制)补丁
为了突破SP2的TCP并发连接数限制,正确地方法是修改Windows XP SP2的系统文件Tcpip.sys。Tcpip.sys是Windows XP SP2重要的系统文件,位于“C:\Window
Linux修改TCP连接数.txt
在Linux系统中,管理和调整TCP连接数和文件数限制是确保系统性能和资源管理的关键步骤。本文主要讲解如何进行以下几个方面的修改:1. **文件数限制修改**: - 在`/etc/secur
TCP-Z - 破解TCP/IP连接数限制让网速飞跃
你是不是觉得你上网速度不够快,这个软件可以给你提速,使用简单方便.在主界面点击补丁,调到10为最高速(数值越小越快).


网络通信/分布式开发
