summaryrefslogtreecommitdiff
path: root/syncClientSocket.cpp
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2008-02-28 22:23:51 +0000
committerOthmar Gsenger <otti@anytun.org>2008-02-28 22:23:51 +0000
commite7d8e749a9ea0b9791ae855bc730d9453534a82e (patch)
tree363c995a182103eed43ae114a05a05e479a79ea4 /syncClientSocket.cpp
parentfixed off by 1 error in sync (diff)
another sync fix
Diffstat (limited to 'syncClientSocket.cpp')
-rw-r--r--syncClientSocket.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/syncClientSocket.cpp b/syncClientSocket.cpp
index 6b791bc..a6f03f4 100644
--- a/syncClientSocket.cpp
+++ b/syncClientSocket.cpp
@@ -49,16 +49,22 @@ void SyncClientSocket::OnRawData(const char *buf,size_t len)
}
while (1)
{
- if(missing_chars==-1 && iss_.str().size()>5)
+ if(missing_chars==-1 && iss_.str().length()>5)
{
- iss_>>missing_chars;
+ char * buffer = new char [missing_chars];
+ iss_.read(buffer,missing_chars);
+ std::stringstream tmp;
+ tmp.write(buffer,missing_chars);
+ tmp>>missing_chars;
+ cLog.msg(Log::PRIO_NOTICE) << "recieved sync inforamtaion from " << GetRemoteHostname() <<" "<<tmp.str()<<"bytes of data"<< std::endl;
+ delete buffer;
} else
- if(missing_chars>0 && missing_chars<static_cast<int16_t>(iss_.str().size()))
+ if(missing_chars>0 && missing_chars<=static_cast<int16_t>(iss_.str().length()))
{
- char * buffer = new char [missing_chars+1];
- iss_.read(buffer,missing_chars+1);
+ char * buffer = new char [missing_chars];
+ iss_.read(buffer,missing_chars);
std::stringstream tmp;
- tmp.write(buffer+1,missing_chars);
+ tmp.write(buffer,missing_chars);
cLog.msg(Log::PRIO_NOTICE) << "recieved sync inforamtaion from " << GetRemoteHostname() <<" \""<<tmp.str()<<'"'<< std::endl;
boost::archive::text_iarchive ia(tmp);
SyncCommand scom(cl_);