Serilization : Using serialization with socket++ for serializing objects over TCP connections : Problem

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
participants (1)
-
nitin motgi