Thanks for the reply, this is a solution.
But I do prefer POE can auto-detect that the server side has send out it's output. I can "telnet" to the server and run these commands, when the command sent out the result, I can input another command. Is any possible way to do it without adding any end mark? | [reply] |
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.
| [reply] |
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
| [reply] |
I can "telnet" to the server and run these commands, when the command sent out the result, I can input another command.
How do you know the command finished sending out the result? By the prompt you are given once it's done. Or maybe because you recognize the format of the output. Or maybe you assumed it was done based on the passing of time. Those are examples of the aforementioned "end of job marker".
A computer cannot detect the appropriate condition without being told what it is. There's too much variety in the possibilities. They usually come in two varieties:
| [reply] [d/l] [select] |
| [reply] |