Q
qiuying
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit2;
interface
uses
Classes,SConnect, SysUtils, Variants;
type
TimerLimit = class(TThread)
private
Socket:TSocketConnection;
Address:String;
protected
procedure Execute;
override;
public
constructor Create(PSocket: TSocketConnection;
PAddress:string);
destructor Destroy;override;
end;
implementation
{ TimerLimit }
constructor TimerLimit.Create(PSocket: TSocketConnection;
PAddress: string);
begin
Socket := PSocket;
Address := PAddress;
FreeOnTerminate := True;
inherited create(false);
end;
destructor TimerLimit.Destroy;
begin
inherited destroy;
end;
procedure TimerLimit.Execute;
begin
FreeOnTerminate :=true ;
Socket.Create(nil);
Socket.Address :=address;
Socket.Port := 211;
if not Socket.Connected then
try
Socket.Connected :=true;
except
Terminate ;
end;
end;
end.
//主程序
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
SocketConnection1.Connected :=false;
TimerLimit.Create(SocketConnection1,edit1.text)
// OnTerminate:= ThreadDone;
end;
第一次可以连接,再连接是会报“ACCESS violation at address...”错误信息。请大家帮忙看一下是什么问题
interface
uses
Classes,SConnect, SysUtils, Variants;
type
TimerLimit = class(TThread)
private
Socket:TSocketConnection;
Address:String;
protected
procedure Execute;
override;
public
constructor Create(PSocket: TSocketConnection;
PAddress:string);
destructor Destroy;override;
end;
implementation
{ TimerLimit }
constructor TimerLimit.Create(PSocket: TSocketConnection;
PAddress: string);
begin
Socket := PSocket;
Address := PAddress;
FreeOnTerminate := True;
inherited create(false);
end;
destructor TimerLimit.Destroy;
begin
inherited destroy;
end;
procedure TimerLimit.Execute;
begin
FreeOnTerminate :=true ;
Socket.Create(nil);
Socket.Address :=address;
Socket.Port := 211;
if not Socket.Connected then
try
Socket.Connected :=true;
except
Terminate ;
end;
end;
end.
//主程序
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
SocketConnection1.Connected :=false;
TimerLimit.Create(SocketConnection1,edit1.text)
// OnTerminate:= ThreadDone;
end;
第一次可以连接,再连接是会报“ACCESS violation at address...”错误信息。请大家帮忙看一下是什么问题