in reply to Optimizing TCP packet usage with IO::Socket::INET or similar
To make transfer as efficient as possible in terms of overhead/payload ratio it is necessary to stuff as much data into tcp packets as possible, having at least padding as possible.
This cannot be controlled from Perl; nor should you try!
You should just send your data in whatever units you get it in -- lines, blocks whatever -- and let the tcpip stack do its job and coalesce or break up those packets into whatever size chunks it knows will be best for the prevailing conditions of the circuit between you and the destination.
Anything you do at the Perl (or most other languages; barring you drop down to raw ip -- DONT!) will simply be undone and reformed into whatever the stack decides is right. And that can vary from connection to connection, and even within the life of a single connection, depending upon the capabilities of the nodes; the prevailing network loading, the routing; et al.
The mechanisms are very well tried & tested, and have been optimised over decades; anything you try is unlikely to beat them and far more likely to interact badly with them, and result in less optimal performance.
(Take this from someone who has tried :)
|
|---|