Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: How to check TIdPeerThread.Connection for input characters?
| Subject: | Re: How to check TIdPeerThread.Connection for input characters? |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Thu, 15 Mar 2007 09:25:53 |
"Mark" <mkhuebner@gmail.com> wrote in message
news:1173966573.311779.45390@y66g2000hsf.googlegroups.com...
> Because I want to close the connection if I'm done reading a
message.
So what is stopping you from doing that? Obviously, you have to know
when the message is finished in the first place, so you can just
Disconnect() the connection right then.
> Isn't this better than keeping a connection open all the time
> even when no data is being transferred?
Not if the messages are being sent frequently. If you really want to
close a connection to reduce overhead, then I suggest you add an idle
counter to the connection. Disconnect it only if no data is received
from the client after a set number of minutes. Don't just blindly
close the connection after each individual message, as the client may
want to send more messages right away. This also allows the client to
decide whether it wants to keep the connection active or not by
sending data periodically. This is a good pinging action that allows
both the server and the client detect whether the other party is still
alive and active.
Gambit