[Botan-devel] Network I/O
barathraghavan at gmail.com
Sat May 26 20:10:57 EDT 2007
I've been using Botan for a few months, and have gotten used to basic
File I/O. What I can't figure out, however, is how to do clean C++
style network I/O.
Here's the basic situation: I have two hosts that want to talk over an
encrypted channel, say using AES/EAX. Their socket interfaces are C++
iostreams (I'm using the asio library that's soon to be part of
Boost). I'd like one host to be able to periodically write a
contiguous message and the other to be able to read it, all through
the encrypted channel.
Suppose I do the following (pseudocode):
ip::tcp::iostream stream(<host>, <port>);
Pipe pipe(get_cipher...); // decryption
The problem here is that stream is a socket that will keep producing
data forever, so the call to pipe.process_msg(in) is not what I want
for several reasons:
1. It treats the input stream as a single contiguous message, but the
input stream of data really might be a bunch of messages (in the sense
of multiple start_msg()/end_msg() calls that were made at the remote
2. It blocks to read all data until EOF, which won't happen until the
socket is closed.
I'd like use the << operator on the pipe to read messages and have
that pull data from the input stream (which happens to be a socket in
this context). Or, similarly, make calls that feed data into the
pipe, but have that call terminate as soon as one message's worth of
data (as readable from the other end of the pipe) has been read from
the input stream.
Any thoughts on how I can achieve this?
More information about the botan-devel