I need a little help sorting out a problem with an app I am writing. I
seem to be getting a memory leak every time I make a new connection. It
seems as though old connections ar not beng destroyed and I am not sure
how I should destroy TTCPEchoThrd threads once they have been used. can
you help?
Lloydie T
---------- CODE ---------------------------
unit main;
{$mode objfpc}{$H+}
interface
uses
cmem,cthreads,Classes, SysUtils, passqlite, BlckSock, synsock, oxounit;
Function CallConv (S1: String): String;
var
LiteDB1 : Tlitedb;
Sock:TTCPBlockSocket;
ClientSock:TSocket;
type
TTCPEchoThrd = class(TThread)
private
Sock:TTCPBlockSocket;
CSock: TSocket;
S:String;
public
Constructor Create (hsock:tSocket);
procedure Execute; override;
end;
tmyconverterfunc=function(AData:String):String;
implementation
var
myconverterfunc:tmyconverterfunc;
Constructor TTCPEchoThrd.Create(Hsock:TSocket);
begin
Csock := Hsock;
FreeOnTerminate:=True;
inherited create(false);
end;
procedure TTCPEchoThrd.Execute;
begin
sock:=TTCPBlockSocket.create;
FreeOnTerminate := True;
try
Sock.socket:=CSock;
sock.GetSins;
with sock do
begin
repeat
if terminated then break;
S := RecvString(1000);
if lastError<>0 then break;
myconverterfunc:[EMAIL PROTECTED];
myconverterfunc(S);
if lastError<>0 then break;
until false;
end;
finally
Sock.Free;
end;
end;
Function CallConv (S1: String): String;
begin
oxoparse1.PbxGet('^[0-9]3',S1,'1');
end;
begin
Sock:=TTCPBlockSocket.create;
with sock do
begin
CreateSocket;
setLinger(true,10);
bind(0.0.0.0,4515);
listen;
repeat
if canread(1000) then
begin
ClientSock:=accept;
if lastError=0 then TTCPEchoThrd.create(ClientSock);
end;
until false;
end;
// end;
end.
---------------------EO
CODE-------------------------------------------------------
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public