求救客户端创建多线程SOCKET连接 Delphi / Windows SDK/APIhttp://www.delphi2007.net/DelphiNetwork/html/delphi_20061123095540275.html
现要给工行做一个连接压力测试软件。需要并发连接服务器。现想到的方法是采用多线程建立SOCKET连接,哪位高手有这方面的源码提供参考一下。我的E-Mail:pigjing211@163.com
QQ:16704804
小弟再次谢过!
没有人我顶
具体要求说一下,急否么。不急可以考虑过几天做一个。
对了我的qq是5928106
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
ClientSocket1: TClientSocket;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure CreatCS();
end;
type
TMyThread = class(TThread)
private
procedure Creat;
{ Private declarations }
protected
procedure Execute; override;
procedure CreatCS;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TMyThread }
procedure TMyThread.Creat;
begin
end;
procedure TMyThread.CreatCS;
begin
Form1.CreatCS;
end;
procedure TMyThread.Execute;
begin
inherited;
Synchronize(CreatCS);
end;
{ TForm1 }
procedure TForm1.CreatCS;
Var
CS:TClientSocket;
begin
CS:=TClientSocket.Create(Self);
CS.Address:=Edit1.Text;
CS.Port:=strtoint(Edit2.Text);
CS.Open;
//sleep(1000);
//CS.Socket.SendText('4100');
Memo1.Lines.Add(formatdatetime('yyyy-MM-dd hh:ss:mm',now)+inttostr(cs.Socket.Handle));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to 10 do
begin
TMyThread.Create(False);
end;
end;
end.
看看是十个线程的SOCKET的连接代码吗?