in reply to How to buffer data?
It sounds like you are working at a much lower level than you need to. I would recommend heading over to www.cpan.org to find what is likely an existing implementation of the problem you are trying to solve. What protocol are you trying to use, or what problem are you trying to solve? Chances are there is an implementation in the Net:: family of modules.