
On Tue, 2005-04-26 at 12:57 -0400, Rob Stewart wrote:
From: "Iain K. Hanson" <ikh@hansons.demon.co.uk>
Using iostreams there must be a buffer ( usually a streambuf ). The buffer size *must* be equal tp the MSS / path MTU.
As the application protocol writter you have to know how much you have written to the buffer *at all times* and you must know when an overflow / flush will happen.
Errors can *only* happen when the buffer writes to the socket ( overflow/flush ) therefore if a programmer does his/her job correctly there will not be multiple operator << traversing and overflow boundary. This is irrespective of sync/async.
According to this, there is no way to use streams with sockets. Otherwise, clients of the stream interface would need to keep track of the size of formatted output of each object inserted on the stream to avoid overflow between insertion operators. How can they do that?
No. But see my previous post for an explanation of how it works. BTW the only formatting I think a socket stream should do is marshaling and that does not effect the number of bytes written when doing things in network byte order. Whether you could use streams with say XDR / BER / DER / PER / CDR marshaling I don't know ( at the moment ) and given that I am working on socket wrappers at the moment, it is not something I intend to give a great deal of consideration just now. /ikh _______________________________________________________________________ This email has been scanned for all known viruses by the MessageLabs Email Security System. _______________________________________________________________________