Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Feb : Server architecture questions (not indy)

www.cryer.info
Managed Newsgroup Archive

Server architecture questions (not indy)

Subject:Server architecture questions (not indy)
Posted by:"Jon Lennart Aasenden" (post_nospam_nojunk@jurasoft.no)
Date:Sun, 20 Feb 2005 01:24:11

Hello.

I am writing a server architecture designed to run in a local area network,
using the core TServerSocket and TClientSocket threaded as a foundation.
The goal is to have a multi-function client/server system, allowing users to
chat and store files on a server "account".
I have divided the server and client system into seperate components, each
doing a specific task. For example, i have a TProtocol component, allowing
me to easily design a protocol - export a manifest file - and import it into
my client components using a delphi designer i made.
Also, i have session managers, request broker, and accound management under
wraps.
A bit like remobjects sdk i guess, except much smaller :)

Question A:

My first question has to do with writing client applications with MDI
windows, as i am experiencing some problems here.
My test app is an MDI application, and i am trying to get all windows to
share the same connection (just an experiment at this point).
To handle this, all client-commands are executed in a thread that calls the
connection component. This component uses a TCriticalsection to assure that
only one command is invoked (sendt and recieved) at any given time.
This works, but i have to use FThread.WaitFor() while executing each send &
recieve.
This freeze my entire application, even forms that are not doing anything!
I then tried to move the entire call into the thread, and call back to my
invocation object when the job was done - but i got access violations.
Somehow a pointer was NIL somewhere when the cycle returned. I then tried
using messages, but by the time the message reached my message handler, the
object was again NIL- and again i got access violations. Finally, i tried
the same, but bolted the reference-count on my TInterfacedObject based class
to 1 - and it worked. But the app crashed on exit....

To all Indy-ans.. I know indy well (use it at work all the time), but i
would like to find a solution using the standard, buildt in delphi socket
classes. So please, no "try indy, its free". I use indy when i can, but this
is another experiment.

So..is there any way of "waiting" for a thread to finish, without freezing
the application?
I have tried callback routines, but they also kill my system. Im not sure,
but i think it has to do with how messages are handled in my main form.

Question B)
I realize ofcourse, that this is what async sockets are all about.
But, while this solves the "client" side of things - it does mayhem server
side (as far as i know). If, for example, the server takes a long time to
produce a result from a request - again the freeze comes into play - but
this time at the server end.
I guess async servers are best for file serving.. any info on async stuff
with delphi is welcome.

Hope someone has some pointers for me.

Kind regards

Jon Lennart Aasenden

Replies:

www.cryer.info
Managed Newsgroup Archive