Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 May : TIdTCPServer / TIdTCPClient business logic...

www.cryer.info
Managed Newsgroup Archive

TIdTCPServer / TIdTCPClient business logic...

Subject:TIdTCPServer / TIdTCPClient business logic...
Posted by:"Gary B" (no@spam.com)
Date:Tue, 10 May 2005 23:51:13

I am using D7 and Indy 10

This is my logic for TIdTCPServer / TIdTCPClient, is it right or wrong?

My Client App Connects to My Server App.

After connecting, The Client WriteLn's "Login".

In the Server's Execute Event, I ReadLn, If = "Login" I go and
DoLogin(aIdConnection: TIdContext)

Server receives UserName, Password and a check is done on a server side
database.

1.) If it returns False, I do: AContext.Connection.Disconnect (Is this right
if what I want is to disconnect only that connection/thread, or an
AContext.RemoveFromList is right?)

2.) If it returns True, I think it is right to store some kind of
identifying info regarding this connection/thread so I have been doing this:
ATStringList.Add(IntToStr(TIdYarnOfThread(AContext.Yarn).Thread.ThreadID)+'='+User).

Why you ask?

Because back in my OnExecute for the Server, if not Connection.Disconnect, I
look for other commands. If a new/different command is sent this is what I
do:

function DoOtherCommand(aIdConnection: TIdContext);
begin

if
ATStringList.IndexOfName(IntToStr(TIdYarnOfThread(AContext.Yarn).Thread.ThreadID))
>= 0
  then begin

         // Do some stuff

        end
  else begin
        AContext.Connection.Disconnect;
        end;

end;

I have been seeing things about ThreadIDs not being a good, because it may
be a Fiber (whatever that is).

Am I way off, am I close, am I worrying too much, am I not worrying enough?

Thanks!

Replies:

www.cryer.info
Managed Newsgroup Archive