in reply to POE: how to flush io?
TCP implementations usually adopt some techniques to send data "packed" together if they can; I'm thinking about optimisation algorithms like Nagle (if I remember well). You don't notice this in telnet, because you probably write your commands and wait for a response - and the initial wait should be sufficient for TCP to decide that it's time to send something. On the other side, your program pumps all the commands together, so if the resources in your machine are enough it will send them all together, while it will probably do something more grateful to you if load is a bit higher.
My quick-and-dirty fix would be putting some delay between requests, or even syncronize them with responses. But the best solution would probably be to make the server more robust and have it accept batches of commands, while doing some caching of a possible truncated command, whose completion could be on its way through the net. Given the fact that I don't know how your server looks like, I cannot say much more!
Flavio
Don't fool yourself.
|
|---|