diff options
author | Othmar Gsenger <otti@anytun.org> | 2008-11-24 22:57:07 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@anytun.org> | 2008-11-24 22:57:07 +0000 |
commit | e63bfdce883c80ee856668fc8cccdf3f5740fb6b (patch) | |
tree | d5121fae7e49a4821ce7325397955cc81267c15a /src/syncClient.cpp | |
parent | fixed sync deletes connection param (diff) |
fixed syncing, config & showtables
Diffstat (limited to 'src/syncClient.cpp')
-rw-r--r-- | src/syncClient.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/syncClient.cpp b/src/syncClient.cpp index 5d4be45..8170990 100644 --- a/src/syncClient.cpp +++ b/src/syncClient.cpp @@ -44,7 +44,7 @@ SyncClient::SyncClient(std::string hostname,std::string port) -:hostname_( hostname),port_(port) +:hostname_( hostname),port_(port),missing_chars(-1) { } @@ -70,26 +70,33 @@ void SyncClient::run() if (error) throw boost::system::system_error(error); - for (;;) + try { - boost::array<char, 128> buf; - boost::system::error_code error; + for (;;) + { + boost::array<char, 1> buf; + boost::system::error_code error; - size_t len = socket.read_some(boost::asio::buffer(buf), error); + size_t len = socket.read_some(boost::asio::buffer(buf), error); - if (error == boost::asio::error::eof) - break; // Connection closed cleanly by peer. - else if (error) - throw boost::system::system_error(error); // Some other error. + if (error == boost::asio::error::eof) + break; // Connection closed cleanly by peer. + else if (error) + throw boost::system::system_error(error); // Some other error. - OnRawData(buf.data(), len); + OnRawData(buf.data(), len); + } + } + catch (std::exception& e) + { + cLog.msg(Log::PRIO_NOTICE) << e.what() << std::endl; } } sleep(10); } catch (std::exception& e) { - std::cerr << e.what() << std::endl; + cLog.msg(Log::PRIO_NOTICE) << e.what() << std::endl; } } @@ -113,7 +120,7 @@ void SyncClient::OnRawData(const char *buf,size_t len) std::stringstream tmp; tmp.write(buffer,6); tmp>>missing_chars; -// cLog.msg(Log::PRIO_NOTICE) << "recieved sync inforamtaion length from " << GetRemoteHostname() <<" "<<tmp.str()<<"bytes of data"<< std::endl; +// cLog.msg(Log::PRIO_NOTICE) << "recieved sync inforamtaion "<<tmp.str()<<"bytes of data"<< std::endl; delete[] buffer; buffer_size_-=6; } else |