Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: IdTCPServer

www.cryer.info
Managed Newsgroup Archive

Re: IdTCPServer

Subject:Re: IdTCPServer
Posted by:"Jamie Dale" (j.da..@turboz.net)
Date:Fri, 9 Jun 2006 14:45:16

> that one below is a potentially problemous :
>
>>     procedure TMyPeerThread.SendToUser(const AUser, AMsg: String);
>>     var
>>         List: TList;
>>         I: Integer;
>>     begin
>>         List := Connection.Server.Threads.LockList;
>>         try
>>             For I := 0 to List.Count-1 do
>>             begin
>>                 with TMyPeerThread(List[I]) do
>>                 begin
>>                     if AnsiSameText(Username, AUser) then
>>                     begin
>>                         SendFrom(Self.Username, AMsg);
>>                         Exit;
>>                     end;
>>                 end;
>>             end;
>>         finally
>>             Connection.Server.Threads.UnlockList;
>>         end;
>>     end;
>
> I had many many problems using a similar approach above. Especially when
> the
> communication is time critical or long delays are not allowed.
> If a dead client socket then the SendFrom may take a lot of time till
> disconnect detected. This is going to block the other threads trying to
> access the server.threads list and also this is going to create a delay
> for
> the threads that are after the "dead" one in receiving the message.
> It is better to create a queue and either use a "writer thread" for each
> client thread to pull and read or check the queue for new data
> periodically
> from the TMyPeerThread .
> Well either ways are possible - all depends what you feel will do a better
> job for you.
> Regards

Blimey!

Well, seems I'm now apparently stuffed either way!

Remy? - Any thoughts? (PS, thanks for the code sample!)

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive