Commit 48d8a18e authored by MONSEIGNE Thibaut's avatar MONSEIGNE Thibaut

Fix: Fedora 25 Build

parent 9cd08f2f
......@@ -52,10 +52,7 @@ protected:
std::ofstream m_dataFile;
public:
~TCPWriterClient()
{
if (m_dataFile.is_open()) { m_dataFile.close(); }
}
~TCPWriterClient() { if (m_dataFile.is_open()) { m_dataFile.close(); } }
TCPWriterClient(io_service& ioService, const char* sAddress, const char* sSignalPort, const char* sStimulusPort, const char* sDataFilename)
: m_stimulusSocket(ioService), m_signalSocket(ioService)
......@@ -73,7 +70,7 @@ public:
m_stimulusSocket.connect(*resolver.resolve(query), error);
// Tell ASIO to read a stimulus
async_read_until(m_stimulusSocket, m_stimulusStream, "\n", boost::bind(&TCPWriterClient::stimulusHandler, this, placeholders::error));
async_read_until(m_stimulusSocket, m_stimulusStream, "\n", boost::bind(&TCPWriterClient::stimulusHandler, this, boost::asio::placeholders::error));
}
if ((sSignalPort != nullptr) && strcmp(sSignalPort, "0") != 0)
......@@ -87,8 +84,7 @@ public:
m_signalSocket.set_option(l_oNoDelay);
// Tell ASIO to read the signal header
async_read(m_signalSocket, buffer(m_signalHeaderBuffer.data(), m_headerSize), transfer_at_least(m_headerSize),
boost::bind(&TCPWriterClient::signalHeaderHandler, this, placeholders::error));
async_read(m_signalSocket, buffer(m_signalHeaderBuffer.data(), m_headerSize), transfer_at_least(m_headerSize), boost::bind(&TCPWriterClient::signalHeaderHandler, this, boost::asio::placeholders::error));
}
}
......@@ -102,8 +98,7 @@ public:
std::cout << "(" << m_signalBytesRead << " bytes of signal read), stimulus: " << &m_stimulusStream;
// Tell ASIO to read again
async_read_until(m_stimulusSocket, m_stimulusStream, "\n",
boost::bind(&TCPWriterClient::stimulusHandler, this, placeholders::error));
async_read_until(m_stimulusSocket, m_stimulusStream, "\n", boost::bind(&TCPWriterClient::stimulusHandler, this, boost::asio::placeholders::error));
}
void signalHeaderHandler(const system::error_code& error)
......@@ -141,13 +136,12 @@ public:
m_signalBuffer.resize(m_bufferSize);
// Tell ASIO to read the actual signal
async_read(m_signalSocket, buffer(m_signalBuffer.data(), m_bufferSize), transfer_at_least(m_bufferSize),
boost::bind(&TCPWriterClient::signalHandler, this, placeholders::error));
async_read(m_signalSocket, buffer(m_signalBuffer.data(), m_bufferSize), transfer_at_least(m_bufferSize), boost::bind(&TCPWriterClient::signalHandler, this, boost::asio::placeholders::error));
}
void signalHandler(const system::error_code& error)
{
if (error == error::eof) { return; } // Connection closed cleanly by peer.
if (error == error::eof) { return; } // Connection closed cleanly by peer.
if (error != nullptr) { throw system::system_error(error); } // Some other error.
// signalBuffer will now contain bufferSize/sizeof(double) amount of samples in doubles. Here we just discard the data.
......@@ -166,8 +160,7 @@ public:
m_signalBytesRead += m_bufferSize;
// Tell ASIO to read more
async_read(m_signalSocket, buffer(m_signalBuffer.data(), m_bufferSize), transfer_at_least(m_bufferSize),
boost::bind(&TCPWriterClient::signalHandler, this, placeholders::error));
async_read(m_signalSocket, buffer(m_signalBuffer.data(), m_bufferSize), transfer_at_least(m_bufferSize), boost::bind(&TCPWriterClient::signalHandler, this, boost::asio::placeholders::error));
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment