diff options
author | Othmar Gsenger <otti@anytun.org> | 2008-02-28 21:30:28 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@anytun.org> | 2008-02-28 21:30:28 +0000 |
commit | 8ddb2c09f6cf2e3781ed660aa28f4e68aeeb4fc5 (patch) | |
tree | 7566f560540433674070fe810476a1497c0842ee /syncClientSocket.cpp | |
parent | removed dummy file (diff) |
new sync protocol
Diffstat (limited to 'syncClientSocket.cpp')
-rw-r--r-- | syncClientSocket.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/syncClientSocket.cpp b/syncClientSocket.cpp index 09faeda..0159f83 100644 --- a/syncClientSocket.cpp +++ b/syncClientSocket.cpp @@ -14,7 +14,7 @@ SyncClientSocket::SyncClientSocket(ISocketHandler& h,ConnectionList & cl) -:TcpSocket(h),cl_(cl),missing_chars(0) +:TcpSocket(h),cl_(cl),missing_chars(-1) { // initial connection timeout setting and number of retries SetConnectTimeout(12); @@ -48,13 +48,22 @@ void SyncClientSocket::OnRawData(const char *buf,size_t len) std::cout << buf[index]; iss_ << buf[index]; } - - while(iss_.good()) + while (1) { - boost::archive::text_iarchive ia(iss_); - SyncCommand scom(cl_); - ia >> scom; + if(missing_chars==-1 && iss_.str().size()>5) + { + iss_>>missing_chars; + } else + if(missing_chars>0 && missing_chars<=static_cast<int16_t>(iss_.str().size())) + { + boost::archive::text_iarchive ia(iss_); + SyncCommand scom(cl_); + ia >> scom; + missing_chars=-1; + } else + break; } + //u_int16_t mux = scom.getMux(); //const ConnectionParam & conn = cl_.getConnection(mux)->second; //cLog.msg(Log::PRIO_NOTICE) << "sync connection #"<<mux<<" remote host " << conn.remote_host_ << ":" << conn.remote_port_ << std::endl; |