diff --git a/src/Application.cpp b/src/Application.cpp index dd94fb43b9..2fe18c161f 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -73,8 +73,7 @@ void Application::run() boost::thread auxThread(boost::bind(&boost::asio::io_service::run, &mAuxService)); auxThread.detach(); - if (!theConfig.RUN_STANDALONE) - mSNTPClient.init(theConfig.SNTP_SERVERS); + mSNTPClient.init(theConfig.SNTP_SERVERS); // // Construct databases. diff --git a/src/SNTPClient.cpp b/src/SNTPClient.cpp index 11a7915fae..d204b6a8ec 100644 --- a/src/SNTPClient.cpp +++ b/src/SNTPClient.cpp @@ -6,6 +6,7 @@ #include #include "utils.h" +#include "Config.h" #include "Log.h" // #define SNTP_DEBUG @@ -43,13 +44,16 @@ static uint8_t SNTPQueryData[48] = SNTPClient::SNTPClient(boost::asio::io_service& service) : mSocket(service), mTimer(service), mResolver(service), mOffset(0), mLastOffsetUpdate((time_t) -1), mReceiveBuffer(256) { - mSocket.open(boost::asio::ip::udp::v4()); - mSocket.async_receive_from(boost::asio::buffer(mReceiveBuffer, 256), mReceiveEndpoint, - boost::bind(&SNTPClient::receivePacket, this, boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); + if (!theConfig.RUN_STANDALONE) + { + mSocket.open(boost::asio::ip::udp::v4()); + mSocket.async_receive_from(boost::asio::buffer(mReceiveBuffer, 256), mReceiveEndpoint, + boost::bind(&SNTPClient::receivePacket, this, boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); - mTimer.expires_from_now(boost::posix_time::seconds(NTP_QUERY_FREQUENCY)); - mTimer.async_wait(boost::bind(&SNTPClient::timerEntry, this, boost::asio::placeholders::error)); + mTimer.expires_from_now(boost::posix_time::seconds(NTP_QUERY_FREQUENCY)); + mTimer.async_wait(boost::bind(&SNTPClient::timerEntry, this, boost::asio::placeholders::error)); + } } void SNTPClient::resolveComplete(const boost::system::error_code& error, boost::asio::ip::udp::resolver::iterator it)