Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Apr : Re: Connection lost due to "connection reset by peer"-error

www.cryer.info
Managed Newsgroup Archive

Re: Connection lost due to "connection reset by peer"-error

Subject:Re: Connection lost due to "connection reset by peer"-error
Posted by:"Shiva" (shi..@gonzo.com)
Date:Thu, 27 Apr 2006 23:58:21

>> I used a critical section to prevent simultaneous access to the logfile
>
> You weren't in the code you showed earlier.
>
You are right. Yesterday I corrected the method LogMessage and that's the
code was talking about. It now looks like this:

procedure TForm1.LogMessage(aMess: string);
var
  f: textfile;

begin
  EnterCriticalSection(CS_LOG);
  try
    assignfile(f, 'c:\test.txt');
    append(f);
    writeln(f, aMess);
    closefile(f);
  finally
    LeaveCriticalSection(CS_LOG);
  end;
end;


>
>> Does the cast TMyNNTPThread(IdTCPClient1) reallocate memory?
>
> No.
>
>> How does this work?
>
> I take it you have never worked with type casting before?  All it is doing

Well, I have, but I thought TIdPeerThread instances were created so I
wondered why you could type cast such an instance to TMyNNTPThread. But now
I understand TMyNNTPThread instances are created due to the statement

        IdTCPServer1.ThreadClass := TMyNNTPThread; // <-- here

as you clearly explained. Thanks a lot Remy!

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive