Discussion:
Indy queue management.
(too old to reply)
D-Fan
2008-07-18 17:32:11 UTC
Permalink
Is there a way to flush the read buffer on a idTCPClient?

Is there a way to tell from the idtcpserver side if the client has
retrieved the message that previously sent from a server?
Remy Lebeau (TeamB)
2008-07-18 18:39:43 UTC
Permalink
Post by D-Fan
Is there a way to flush the read buffer on a idTCPClient?
For what purpose exactly? Please elaborate.
Post by D-Fan
Is there a way to tell from the idtcpserver side if the
client has retrieved the message that previously sent
from a server?
The only way is to have the client explicitally send an acknowledgement back
to the server.


Gambit
D-Fan
2008-07-18 19:35:01 UTC
Permalink
Post by Remy Lebeau (TeamB)
Post by D-Fan
Is there a way to flush the read buffer on a idTCPClient?
For what purpose exactly? Please elaborate.
If I read a certain value then I want to be able flush any other
incoming contents prior to sending an acknowledgment. This is because
my acknowledgment is to cause the server to send me a specific type of
data. If the buffer is not flushed other data in the buffer might
contaminate the message that I will be looking for once the message has
been acknowledged.
Post by Remy Lebeau (TeamB)
Post by D-Fan
Is there a way to tell from the idtcpserver side if the
client has retrieved the message that previously sent
from a server?
The only way is to have the client explicitally send an acknowledgement back
to the server.
I get this.
Post by Remy Lebeau (TeamB)
Gambit
Remy Lebeau (TeamB)
2008-07-18 20:07:45 UTC
Permalink
Post by D-Fan
If I read a certain value then I want to be able flush
any other incoming contents prior to sending an
acknowledgment.
The only way to flush a socket's inbound buffer is to simply read from it
until there is nothing more to read.
Post by D-Fan
This is because my acknowledgment is to cause the server to
send me a specific type of data. If the buffer is not flushed
other data in the buffer might contaminate the message that I
will be looking for once the message has been acknowledged.
Sounds like you are not reading previous data from the socket before sending
the acknowledgement. What exactly are you acknowledging, and what exactly
is the server sending in reply?


Gambit
D-Fan
2008-07-19 00:47:54 UTC
Permalink
Post by Remy Lebeau (TeamB)
Post by D-Fan
If I read a certain value then I want to be able flush
any other incoming contents prior to sending an
acknowledgment.
The only way to flush a socket's inbound buffer is to simply read from it
until there is nothing more to read.
Post by D-Fan
This is because my acknowledgment is to cause the server to
send me a specific type of data. If the buffer is not flushed
other data in the buffer might contaminate the message that I
will be looking for once the message has been acknowledged.
Sounds like you are not reading previous data from the socket before sending
the acknowledgement. What exactly are you acknowledging, and what exactly
is the server sending in reply?
Gambit
I have a server process that will send me an unsolicited request via a
flag, etc. The Flag might be a certain character like the letter "B".
The letter "B" use telling me that There is information from me on the
server. So, I respond with a value and the server will respond with the
messages that I have. The issue that I am looking looking to avoid is
one where the server send me multiple requests like 3 "B"'s before I get
a chance to respond to the first one. Once I get the first "B" I want
to flush the remaining values from the receive buffer before sending my
acknowledge back. This will help ensure that my actual response will be
to the firs command that I read. I truly hope that this makes sense.
Remy Lebeau (TeamB)
2008-07-20 07:33:49 UTC
Permalink
Post by D-Fan
I have a server process that will send me an unsolicited request via
a flag, etc. The Flag might be a certain character like the letter "B".
The letter "B" use telling me that There is information from me on
the server.
You don't need to flush the socket in order to handle such messages. You
do, however, need to design your protocol so that every packet has a header
on it (if you have not already done so) so that the client can determine
whether a given packet is an unsolicited message versus a reply to a comment
it sent to the server. You also need to make sure the server is sending
packets in a thread-safe manner so packets cannot overlap. And you need to
design both client and server to handle everything asynchronously so that an
unsolicated message is allowed to be sent while the server is doing other
things, and can arrive while the client is waiting for other data.
Post by D-Fan
So, I respond with a value and the server will respond with the
messages that I have.
You don't need to send any acknowledgement in that situation. Have the
request for messages be its own command that the client can send to the
server at any time. The server message is just a notification to let the
client know that messages are available, nothing else. The client can then
send the request when it is ready to do so, and does not need to acknowledge
the server's notification.
Post by D-Fan
The issue that I am looking looking to avoid is one where the server
send me multiple requests like 3 "B"'s before I get a chance to
respond to the first one. Once I get the first "B" I want to flush
the remaining values from the receive buffer before sending my
acknowledge back.
You are going about this all wrong. You should not be trying to flush
anything at all. Let the multiple "B" messages arrive normally. Simply set
a flag for yourself when the first one arrives, ignore any subsequent ones
that arrive while the flag is still set, and then clear the flag once you
send your request.


Gambit

Loading...