OpenDaVINCI  4.16.0
odcore::wrapper::WIN32Impl::WIN32TCPConnection Class Reference

#include <WIN32TCPConnection.h>

Inheritance diagram for odcore::wrapper::WIN32Impl::WIN32TCPConnection:
Inheritance graph

Public Member Functions

 WIN32TCPConnection (const int32_t &fileDescriptor)
 
 WIN32TCPConnection (const std::string &ip, const uint32_t &port)
 
virtual ~WIN32TCPConnection ()
 
virtual void sendImplementation (const std::string &data)
 
virtual void start ()
 
virtual void stop ()
 
virtual bool isRunning ()
 
virtual void run ()
 
void send (const string &data)
 
void setConnectionListener (ConnectionListener *cl)
 
void setStringListener (StringListener *listener)
 
bool isRaw () const
 
void setRaw (const bool &raw)
 

Protected Types

enum  { BUFFER_SIZE = 65535 }
 

Protected Member Functions

void initialize ()
 
void receivedString (const string &partialData)
 
void invokeConnectionListener ()
 

Protected Attributes

unique_ptr< Threadm_thread
 
unique_ptr< Mutexm_socketMutex
 
int32_t m_fileDescriptor
 
char m_buffer [BUFFER_SIZE]
 
std::string m_ip
 
uint32_t m_port
 

Member Enumeration Documentation

anonymous enum
protected
Enumerator
BUFFER_SIZE 

Constructor & Destructor Documentation

odcore::wrapper::WIN32Impl::WIN32TCPConnection::WIN32TCPConnection ( const int32_t &  fileDescriptor)

References initialize().

odcore::wrapper::WIN32Impl::WIN32TCPConnection::WIN32TCPConnection ( const std::string &  ip,
const uint32_t &  port 
)

References initialize(), and m_fileDescriptor.

odcore::wrapper::WIN32Impl::WIN32TCPConnection::~WIN32TCPConnection ( )
virtual

References m_fileDescriptor, and stop().

Member Function Documentation

void odcore::wrapper::WIN32Impl::WIN32TCPConnection::initialize ( )
protected
void odcore::io::tcp::TCPConnection::invokeConnectionListener ( )
protectedinherited
bool odcore::io::tcp::TCPConnection::isRaw ( ) const
inherited

This method returns if we have configured a raw TCP connection (i.e. without the size of the payload information).

Referenced by odcore::io::tcp::TCPConnection::receivedString(), and odcore::io::tcp::TCPConnection::send().

bool odcore::wrapper::WIN32Impl::WIN32TCPConnection::isRunning ( )
virtual

This method returns true, iff this runnable is in its internal state for running.

Returns
true iff this runnable is in its internal state for running.

Implements odcore::wrapper::Runnable.

References m_thread.

Referenced by run().

void odcore::io::tcp::TCPConnection::receivedString ( const string &  partialData)
protectedinherited

This method has to be called by subclasses whenever new (partial) data was received. This method is responsible for gathering partial data and invoking the registered StringListener when a complete data packet was gathered.

Parameters
partialDataPartially received data that will be gathered until the complete data can be passed to the registered StringListener.

References odcore::io::tcp::TCPConnection::isRaw().

Referenced by odcore::wrapper::POSIX::POSIXTCPConnection::run(), and run().

void odcore::wrapper::WIN32Impl::WIN32TCPConnection::run ( )
virtual
void odcore::io::tcp::TCPConnection::send ( const string &  data)
inherited

This method is used to send data using this TCP connection.

Parameters
dataData to send.

References odcore::io::tcp::TCPConnection::isRaw(), and odcore::io::tcp::TCPConnection::sendImplementation().

Referenced by odcore::wrapper::POSIX::POSIXTCPConnection::sendImplementation(), and sendImplementation().

void odcore::wrapper::WIN32Impl::WIN32TCPConnection::sendImplementation ( const std::string &  data)
virtual

This method has to be implemented in subclasses to send data. It is called from within the send()- method.

param data Data with prepended size information.

Implements odcore::io::tcp::TCPConnection.

References odcore::io::tcp::TCPConnection::invokeConnectionListener(), m_fileDescriptor, m_socketMutex, and odcore::io::tcp::TCPConnection::send().

void odcore::io::tcp::TCPConnection::setConnectionListener ( ConnectionListener cl)
virtualinherited

This method registers a ConnectionListener that will be informed about connection errors.

Parameters
clThe ConnectionListener

Implements odcore::io::ConnectionObserver.

Referenced by odcore::io::tcp::TCPConnection::~TCPConnection().

void odcore::io::tcp::TCPConnection::setRaw ( const bool &  raw)
inherited

This method configures a TCP connection to just transport the raw bytes.

void odcore::io::tcp::TCPConnection::setStringListener ( StringListener listener)
virtualinherited

This method sets the StringListener that will receive incoming data.

Parameters
listenerStringListener that will receive incoming data.

Implements odcore::io::StringObserver.

Referenced by odcore::io::tcp::TCPConnection::~TCPConnection().

void odcore::wrapper::WIN32Impl::WIN32TCPConnection::start ( )
virtual

This method must be called to start the connection.

Implements odcore::io::tcp::TCPConnection.

References m_thread.

void odcore::wrapper::WIN32Impl::WIN32TCPConnection::stop ( )
virtual

This method closes a connection.

Implements odcore::io::tcp::TCPConnection.

References m_thread.

Referenced by ~WIN32TCPConnection().

Member Data Documentation

char odcore::wrapper::WIN32Impl::WIN32TCPConnection::m_buffer[BUFFER_SIZE]
protected

Referenced by run().

int32_t odcore::wrapper::WIN32Impl::WIN32TCPConnection::m_fileDescriptor
protected
std::string odcore::wrapper::WIN32Impl::WIN32TCPConnection::m_ip
protected
uint32_t odcore::wrapper::WIN32Impl::WIN32TCPConnection::m_port
protected
unique_ptr<Mutex> odcore::wrapper::WIN32Impl::WIN32TCPConnection::m_socketMutex
protected

Referenced by initialize(), and sendImplementation().

unique_ptr<Thread> odcore::wrapper::WIN32Impl::WIN32TCPConnection::m_thread
protected

Referenced by initialize(), isRunning(), start(), and stop().