17 #include "connectiontcpclient.h"
20 #include "mutexguard.h"
27 #if ( !defined( _WIN32 ) && !defined( _WIN32_WCE ) ) || defined( __SYMBIAN32__ )
28 # include <sys/types.h>
29 # include <sys/socket.h>
30 # include <sys/select.h>
34 #elif ( defined( _WIN32 ) || defined( _WIN32_WCE ) ) && !defined( __SYMBIAN32__ )
45 const std::string& server,
int port )
51 const std::string& server,
int port )
100 m_server +
": connection refused" );
108 "Unknown error condition" );
128 if( m_cancel || m_socket < 0 )
134 if( !dataAvailable( timeout ) )
140 int size =
static_cast<int>(
::recv( m_socket, m_buf, m_bufsize, 0 ) );
142 m_totalBytesIn += size;
151 std::string message =
"recv() failed. "
152 #if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
153 "WSAGetLastError: " + util::int2string( ::WSAGetLastError() );
155 "errno: " + util::int2string( errno ) +
": " + strerror( errno );
An abstract base class for a connection.
void err(LogArea area, const std::string &message) const
virtual ConnectionBase * newInstance() const
virtual void handleReceivedData(const ConnectionBase *connection, const std::string &data)=0
This is an abstract base class to receive events from a ConnectionBase-derived object.
This is a base class for a simple TCP connection.
ConnectionTCPClient(const LogSink &logInstance, const std::string &server, int port=-1)
virtual void handleDisconnect(const ConnectionBase *connection, ConnectionError reason)=0
The namespace for the gloox library.
virtual void handleConnect(const ConnectionBase *connection)=0
virtual ConnectionError connect()
ConnectionDataHandler * m_handler
static int connect(const std::string &host, const LogSink &logInstance)
virtual ConnectionError recv(int timeout=-1)
An implementation of log sink and source.
virtual ~ConnectionTCPClient()