Boost logo

Boost Users :

From: nitin motgi (nitin.motgi_at_[hidden])
Date: 2005-07-19 19:10:07


Hi All,

I using boost::archive and socket++ libraries for serializing objects
over TCP connections. Socket++ provides iosockinet class which is a
derivative of iostream that supports i/o with two different buffers.

Upon binding the iosockinet to a port I assign it to binary_iarchive
and oarchive upon doing so .. the program aborts immediately. I am not
sure what is causing this problem. Any help in this would be
appreciated.

================= serialize_common.h ========================
class serialize_common {
private:
        friend class boost::serialization::access;
        string name;
        int iVal;

        long lVal;
        unsigned int uiVal;
        float fVal;
        double dVal;

        template <class Archive>
        void serialize(Archive& ar, const unsigned int version) {
                ar & name;
                ar & iVal;
                ar & lVal;
                ar & uiVal;
                ar & fVal;
                ar & dVal;
        }
public:
           . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
           . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
           . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
   };
================= test.cpp ==================================
/*
1. sockinetbuf is derived from sockbuf
2. iosockinet is derived from iosockstream which inturn is
        derived from iostream

*/
#include <sockinet.h>
#include "serialize_common.h"

int main() {
        serialize_common command;
        sockinetbuf si(sockbuf::sock_stream);
        si.bind();

        cout << si.localhost() << ' ' << si.localport() << endl;
        si.listen();

        while(1) {
                iosockinet s(si.accept());

                boost::archive::binary_oarchive ao(s); <== Modifies s
which comes non usable
                boost::archive::binary_iarchive ao(s); <== Aborts at this point

                char buf[1024];

                while (s >> buf) {
                        cout << buf << ' ';
                        s << ::strlen(buf) << endl;
                }

                cout << endl;
        }

        return 0;
}

Thank you,
Nitin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net