C
cnmir
Unregistered / Unconfirmed
GUEST, unregistred user!
网上找了点资料,但是还是出错了,哪位大哥能帮忙看看
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, D7ScktComp;
const
SNum = 10;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
ServerSockets: array of TServerSocket;
procedure MyOnClientConnect(Sender: TObject; Socket: TCustomWinSocket);
{ Public declarations }
end;
var
Form1 : TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
const SNum = 10;
var i : integer;
begin
ServerSockets := VarArrayCreate([0, SNum - 1], varVariant);
for i := 0 to SNum - 1 do
begin
ServerSockets := TServerSocket.Create(self);
with ServerSockets do
begin
Active := false;
Port := i;
OnClientConnect := MyOnClientConnect;
Active := true;
end;
end;
end;
procedure TForm1.MyOnClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
//how do you do???
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var i : integer;
begin
for i := 0 to SNum - 1 do
begin
ServerSockets.Active := false;
end;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, D7ScktComp;
const
SNum = 10;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
ServerSockets: array of TServerSocket;
procedure MyOnClientConnect(Sender: TObject; Socket: TCustomWinSocket);
{ Public declarations }
end;
var
Form1 : TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
const SNum = 10;
var i : integer;
begin
ServerSockets := VarArrayCreate([0, SNum - 1], varVariant);
for i := 0 to SNum - 1 do
begin
ServerSockets := TServerSocket.Create(self);
with ServerSockets do
begin
Active := false;
Port := i;
OnClientConnect := MyOnClientConnect;
Active := true;
end;
end;
end;
procedure TForm1.MyOnClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
//how do you do???
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var i : integer;
begin
for i := 0 to SNum - 1 do
begin
ServerSockets.Active := false;
end;
end;
end.