|
|
@ -8,6 +8,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @todo make connection an iface and this class shall be a TcpConnection,
|
|
|
|
|
|
|
|
* inherited from connection */
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
template <typename T>
|
|
|
|
class Connection
|
|
|
|
class Connection
|
|
|
@ -95,27 +97,23 @@ public:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TRACE;
|
|
|
|
TRACE;
|
|
|
|
|
|
|
|
|
|
|
|
// LOG ( Logger::DEBUG, std::string("receving on socket: ").
|
|
|
|
ssize_t length;
|
|
|
|
// append(TToStr(m_socket.getSocket())).c_str() );
|
|
|
|
if ( !m_socket.receive(m_buffer, m_bufferLength, &length) ) {
|
|
|
|
|
|
|
|
if (length == -1) {
|
|
|
|
ssize_t len = recv(m_socket.getSocket(), m_buffer, m_bufferLength, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG ( Logger::DEBUG, std::string("Received: ").
|
|
|
|
|
|
|
|
append(TToStr(len)).append(" bytes from: ").
|
|
|
|
|
|
|
|
append(m_host).append(":").append(m_port).c_str() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (len == -1) {
|
|
|
|
|
|
|
|
LOG( Logger::ERR, errnoToString("ERROR reading from socket. ").c_str() );
|
|
|
|
LOG( Logger::ERR, errnoToString("ERROR reading from socket. ").c_str() );
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (length == 0) {
|
|
|
|
if (len == 0) {
|
|
|
|
|
|
|
|
LOG( Logger::INFO, std::string("Connection closed by ").
|
|
|
|
LOG( Logger::INFO, std::string("Connection closed by ").
|
|
|
|
append(m_host).append(":").append(m_port).c_str() );
|
|
|
|
append(m_host).append(":").append(m_port).c_str() );
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return m_message.buildMessage( (void*)m_buffer, (size_t)len);
|
|
|
|
LOG ( Logger::DEBUG, std::string("Received: ").
|
|
|
|
|
|
|
|
append(TToStr(length)).append(" bytes from: ").
|
|
|
|
|
|
|
|
append(m_host).append(":").append(m_port).c_str() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return m_message.buildMessage( (void*)m_buffer, (size_t)length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|