Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Apr : Re: Delphi 7 & Indy 10 TidCmdTCPServer OnCommand Event
| Subject: | Re: Delphi 7 & Indy 10 TidCmdTCPServer OnCommand Event |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Thu, 12 Apr 2007 15:14:38 |
"Codeman II" <thegentleman@webmail.co.za> wrote in message
news:461ea26d@newsgroups.borland.com...
> Should I rather have a client connect to the server with the
relevant
> command and leave the connection open until the client software are
> closed OR must the client rather connect to server each time it
wants
> to send a command in immediately afterwards disconnect (close
connection)?
That is entirely dependant on the protocol you are implementing. Some
work one way, others work the other way.
If a client is going to be sending commands fairly often, it is
generally best to leave the connection open, and require periodic
commands, even if just keepalives. Establishing a new connection has
some overhead to it on both sides. On the other hand, if a client is
not going to be sending any commands for awhile, it is generally
better to disconnect so that resources can be released.
> The code snippet I was refering to, it only checks for open / active
> connections?
That is what is stored in the server's Contexts list. There is no
need for it to keep track of disconnected clients.
> But if I disconnect / close the connection, for example with my
> "Quit" commandhandler, the server component won't have it in it's
> list anymore?
Correct.
Gambit