[Botan-devel] Sending raw, unencoded data over a network

Z. S. O. tiredashell at gmail.com
Mon Apr 13 23:57:17 EDT 2009

After much searching, I figured out how to do it...but it's a bit "hacky."
Basically, I realized that although chars can't hold binary data, strings
and vectors can. So you basically have to make the buffer point to a vector
of chars as so:
vector<char> myVector(1024);
char *buffer = &(myVector[0]);

int len = recv(socket, buffer, 1024);

string data;
for (int i; i<len; i++)
data += myVector.at(i);

The string "data" will then hold the correct binary data. Hope this helps
anyone who runs into the same issue.

On Mon, Apr 13, 2009 at 8:04 PM, Jack Lloyd <lloyd at randombit.net> wrote:

> On Mon, Apr 13, 2009 at 03:23:14PM -0400, Z. S. O. wrote:
> > Yes, recv returns the actual data size, but that's after it has already
> been
> > copied into the buffer. It looks like this:
> > int len = recv(socket, buffer, 1024);
> >
> > So buffer already will only contain part of the data, and the rest is
> > presumably lost. I'm trying to ask this on a networking-oriented mailing
> > list because I don't want to bother you with off-topic questions, but if
> you
> > have experience with this I'm open to any suggestions. Thanks.
> Nothing pops out to me. I think the first thing I'd try here is
> running tcpdump on the line and seeing if the packet on the wire
> contains the full contents or not. That at least cuts the problem
> space in half and you can know to dig further into the sender or the
> receiver.
> -Jack
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://lists.randombit.net/mailman/listinfo/botan-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20090413/b9cd3e46/attachment.html>

More information about the botan-devel mailing list