Board index » delphi » Nobody else has this problem with winsock ?

Nobody else has this problem with winsock ?

I'm trying to make a program that must run unattended.

This opens a winsock channel to get some data from a remote device.
If the connection doesn't succeed, the program must keep trying
forever.

The trouble is that each time the attempt times out, the program leaks
some memory.

I'm getting crazy about this problem.

I've read everything about the subject, included the Microsoft Q171996
that talks about a possible fix to tcpip but i'm unable to find it.

Any suggestion ?

Regards

-------------------
ferre...@selesta.it
-------------------

 

Re:Nobody else has this problem with winsock ?


There is probably a leak in your probably a leak in your program - but you
haven't provided enough information for us to be able to help you.

You may want to use 3rd-party internet controls (many free), like
TWinSocket.

D. Filion

Maurizio Ferreira a crit dans le message
<35595b73.5719...@forums.borland.com>...

Quote
>I'm trying to make a program that must run unattended.

>This opens a winsock channel to get some data from a remote device.
>If the connection doesn't succeed, the program must keep trying
>forever.

>The trouble is that each time the attempt times out, the program leaks
>some memory.

>I'm getting crazy about this problem.

>I've read everything about the subject, included the Microsoft Q171996
>that talks about a possible fix to tcpip but i'm unable to find it.

>Any suggestion ?

>Regards

>-------------------
>ferre...@selesta.it
>-------------------

Re:Nobody else has this problem with winsock ?


"D. Filion" <dfilion@(anti-spam insert)globetete.com> wrote:

Quote
>There is probably a leak in your probably a leak in your program - but you
>haven't provided enough information for us to be able to help you.

>You may want to use 3rd-party internet controls (many free), like
>TWinSocket.

>D. Filion

I think it's neither VCL fault or my program fault, but something
related to winsock32.dll.

Anyway it's simple to cause the problem.

Just place a tclientsocket component on a form,
a button to start it, with the following code,

procedure TForm1.btStartClick(Sender: TObject);
begin
  with sock do begin
    Address := '200.0.0.1';
    port := 2502;
    onError := error;
    Open;
  end;
end;

and the following OnError procedure.

procedure tForm1.Error (Sender: TObject; Socket: TCustomWinSocket;
          ErrorEvent: TErrorEvent; var ErrorCode: Integer);
begin
    ErrorCode := 0;
   with Sender as tClientSocket do
      if not Active then Open;
end;

As you can see, after several attempts the system loses some memory.

I'ts not  a recursion problem or something like that (I've checked the
stack pointer and it's always the same value).

Since the leak is very small and occurs ONLY if the connection
does not succeed, it's easy to overlook the problem,
but if the program runs unattended for several days it leads the
machine to a crash.

Regards
Maurizio

-------------------
ferre...@selesta.it
-------------------

Other Threads