Hi,
I have a POE script which acts as a server, listening for tcp
connections on a port (using POE::Wheel::SocketFactory). When a client
connects, i create a POE::Wheel::ReadWrite for reading the incoming
data.
The client then starts sending data (composed of a sequence of
messages), and then closes the connection... the protocol used does
not have a "goodbye" or "End of transmission" sequence or any flow control.
The client can send one or more messages on a single connection, but doesn't
say how many messages it will send, or how many it has sent. I don't
control the client, so I can't change this simple protocol.
My problem is that the client can send the data too quickly for
me to process. Each individual message in a connection is read and
processed sequentially in my POE script (all done through POE events)...
the processing of each message takes around 5 seconds or so.
If a client quickly sends 15 or so messages and then closes the
connection, my POE script has by this time just gotten the ReadWrite InputEvent for
message number 8 or so, and is still lagging behind processing them.
That wouldn't be such a problem, but then the ErrorEvent for the wheel
gets notified (because of the closed connection), and there i detect that
the connection has been closed (function is read and errnum is 0) and shutdown
the wheel. So I end up reading around 8 messages of the 15 that were sent,
because the ErrorEvent is being kicked in before all of the fifteen InputEvent's.
The remaining InputEvent's are probably in some dispatch queue
inside POE, because the socket's already been closed, and all the data
from it has been read. When i kill the Wheel in the "early" ErrorEvent,
those remaining InputEvents are discarded without being delivered to
my session..
Is there any way out of this, without having to redesign the
protocol to include flow control or EOTs (I cant change the client)? I tried
using pause_input() and resume_input(), but without success. Correct
me if I'm wrong, but if there was a way to see if there are any pending
events (more specifically, InputEvents) to be received for a Wheel, I
could check this out in the ErrorEvent, and only close the Wheel when
all the InputEvents have been received.
Im using ActiveState perl 5.6.1 on a Windows 2K PRO system, with POE version
0.23. Thanks for any help.
Cristiano Lincoln Mattos