in reply to Re^2: How can I determine the server is waiting for input in POE::Wheel::ReadWrite?
in thread How can I determine the server is waiting for input in POE::Wheel::ReadWrite?

Hi,

When you send messages across a network, they get chopped up into pieces. The problem is: you cannot know ahead of time how many pieces the message will get chopped up into. Therefore, the only way to know when to stop trying to read the bits and pieces of the messages coming across the network is if there is some kind of "end of message" marker.

Some other "end of message" markers are: If the other side of the connection is always guaranteed to send messages of the same length, you can stop reading after receiving x number of bytes. Or, if the other side always uses the first two bytes of the message to indicate how many bytes the message length is, you can read the first two bytes, then read the next x number of bytes after that and then stop reading. Or, if the other side always closes the connection after sending a message, you can use that event as an end of message marker.

But the bottom line is you can't automatically detect when to stop reading because you can't know ahead of time how many pieces your message got chopped up into when it was sent across the network.

I hope that helps shed some light on the situation.

  • Comment on Re^3: How can I determine the server is waiting for input in POE::Wheel::ReadWrite?

Replies are listed 'Best First'.
Re^4: How can I determine the server is waiting for input in POE::Wheel::ReadWrite?
by woosley (Beadle) on Nov 15, 2009 at 10:23 UTC
    Thanks, you really did a lot of help. I think I have some confusion in the basic idea of net work programming which this reply clarified. So the choice is to set a end mark for each command.
    thanks all