Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: How to check TIdPeerThread.Connection for input characters?

www.cryer.info
Managed Newsgroup Archive

Re: How to check TIdPeerThread.Connection for input characters?

Subject:Re: How to check TIdPeerThread.Connection for input characters?
Posted by:"Mark" (mkhuebn..@gmail.com)
Date:15 Mar 2007 11:59:37

On Mar 15, 1:25 pm, "Remy Lebeau \(TeamB\)" <no.s...@no.spam.com>
wrote:
> "Mark" <mkhueb...@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.
I was hoping there would be a property that I could read that would
tell me if there is another message or ACK/NAK after the first
message.  This property would tell me the number of characters
remaining in the buffer to be read.  I'm currently using ReadLn(ETX)
so it will stop reading when it detects an ETX character.  Does the
IdTCPServerExecute(AThread: TIdPeerThread) event fire when the first
character of a message arrives or after the last character arrives or
at some other time?

>
> > 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.
I get a poll message from the instrument at least every 15 seconds or
every 1 second when the instrument is not busy and the instrument
needs to get an ACK/NAK back within 1 second.  The messages are
anywhere from 25 to, say, 300 characters long.  My company has a high
bandwidth network but everyone uses the network for business and we
just got Cisco VOIP phones.  My Windows service will be receiving poll
messages 24/7  I was planning on closing the connection after sending
out the ACK/NAK.  If I NAK a message, the instrument will attempt to
send it again.  What do you recommend in this case about closing the
connection?  Should I close it if a message is ACK'ed?

>
> Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive