Boost logo

Boost :

From: Stefan (gentoopower_at_[hidden])
Date: 2005-10-03 16:48:41


Hi folks,

I just tested the boost serialization library.
I have a question:

I need to serialize my objects and then transfer them via tcp connection.
Right now I write them into a file like in the examples and then open
this file again read it with getc into an array, then send it.
Is there an easier way without writing to a file, since this would be a
problem with my performance.

This is what I do right now:

const GPSData g(10,10,10.0);
std::ostream teststream;
std::ofstream ofs("filename");
boost::archive::text_oarchive oa(teststream);
oa << g;
ofs.close();

char serializedobj[100], c;
FILE * fp;
fp=fopen("filename", "rw");
int cnt=0;
while((c=getc(fp)) !=EOF)
{
serializedobj[cnt]=c;
cnt++;
}
serializedobj[cnt]='\0';
tcpclient->send(serializedobj);

Thanks in advance, Stefan

                
___________________________________________________________
Was denken Sie über E-Mail? Wir hören auf Ihre Meinung: http://surveylink.yahoo.com/wix/p0379378.aspx


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk