Kanzi Connect  3.9.9
Kanzi Connect C++ API
kanzi::connect::ClientSocketConnectionAdapter Class Referenceabstract

A class that implements connection adapter for TCP-IP transport type. More...

#include <connection_adapter_socket_client.hpp>

Inheritance diagram for kanzi::connect::ClientSocketConnectionAdapter:
kanzi::connect::ClientConnectionAdapter

Public Member Functions

 ClientSocketConnectionAdapter (int socketType)
 Constructor. More...
 
virtual bool configure (const ClientConnectionAdapter::Parameters &parameters)
 See ConnectionAdapter::configure. More...
 
virtual bool connect ()
 See ConnectionAdapter::connect. More...
 
virtual void disconnect ()
 See ConnectionAdapter::disconnect. More...
 
virtual string getState (const string &parameter)
 See ConnectionAdapter::getState. More...
 
virtual void interrupt ()
 See ConnectionAdapter::interrupt. More...
 
virtual int wait ()
 See ConnectionAdapter::wait. More...
 
virtual void work (int status)
 See ConnectionAdapter::work. More...
 
virtual ~ClientSocketConnectionAdapter ()
 Destructor. More...
 
- Public Member Functions inherited from kanzi::connect::ClientConnectionAdapter
virtual void aboutToStop ()
 Invoked when the adapter should stop. Called before the object will be destroyed. More...
 
void addObserver (Observer *observer)
 Adds observer to receive notification from this adapter. More...
 
 ClientConnectionAdapter ()
 Constructor. More...
 
virtual shared_ptr< MessageTranslatorgetNetworkTranslator (MessagePackage::SerializationFormat format=MessagePackage::SerializationFormatBinary)
 
virtual string getParameter (const string &parameter)
 Adapter can expose it's parameters using key-value pairs. More...
 
virtual string getType () const =0
 Returns type of the adapter, this needs to be unique for every adapter. More...
 
void removeObserver (Observer *observer)
 Removes observer from this adapter. More...
 
virtual void send (const vector< char > &data)=0
 Sends data to network. More...
 
virtual void setClient (Client *client)
 Allows to set a pointer to the Client instance for this adapter. More...
 
virtual ~ClientConnectionAdapter ()
 Destructor. More...
 

Static Public Attributes

static const string PARAMETER_HOST_IP
 Configuration parameter for server ip address. More...
 
static const string PARAMETER_HOST_PORT
 Configuration parameter for server port. More...
 
static const string STATE_IP
 State parameter to read adapter ip address back. More...
 
static const string STATE_PORT
 State parameter to read adapter port back. More...
 

Protected Member Functions

void clearTxQueue ()
 Clears the transmit queue. More...
 
void discardFromTxQueue (size_t bytes)
 Discards data (after being sent) from tx queue. More...
 
virtual bool hasPendingTxSocketData ()
 Determine whether the client implementation has pending data to write. More...
 
bool queueTxData (const vector< char > &data, size_t maxQueueDepth, size_t position=0)
 Tries to queue given buffer to tx queue. More...
 
virtual void read ()=0
 Do the reading from socket. More...
 
virtual void sendPendingTxSocketData ()
 Write pending data into the socket. More...
 
- Protected Member Functions inherited from kanzi::connect::ClientConnectionAdapter
void notifyConnected ()
 Allows derived class to invoke connection notification to all observers. More...
 
void notifyDisconnected ()
 Allows derived class to invoke disconnect notification to all observers. More...
 
void notifyReceive (const vector< char > &data)
 Allows derived class to invoke data received notification to all observers. More...
 

Protected Attributes

recursive_mutex m_mutex
 
int m_port
 Configured server port. More...
 
string m_server
 Configured server address. More...
 
::fd_set * m_set
 Activated sockets during wait. More...
 
int m_signal [2]
 
Socketm_socket
 Socket used by this adapter. More...
 
int m_socketType
 Socket type. More...
 
vector< char > m_txBuffer
 
int m_workResult
 Result of wait is stored here. More...
 
::fd_set * m_writeSet
 

Additional Inherited Members

- Public Types inherited from kanzi::connect::ClientConnectionAdapter
typedef map< string, string > Parameters
 Container type for parameters. More...
 
- Static Protected Member Functions inherited from kanzi::connect::ClientConnectionAdapter
static string getConfigurationParameterString (const Parameters &parameters, const string &parameter)
 Get single single string type configuration parameter. Returns empty string for missing parameter. More...
 

Detailed Description

A class that implements connection adapter for TCP-IP transport type.

Constructor & Destructor Documentation

◆ ClientSocketConnectionAdapter()

kanzi::connect::ClientSocketConnectionAdapter::ClientSocketConnectionAdapter ( int  socketType)

Constructor.

Parameters
socketTypeSets the type of the socket to be created (either streaming or datagram).

◆ ~ClientSocketConnectionAdapter()

virtual kanzi::connect::ClientSocketConnectionAdapter::~ClientSocketConnectionAdapter ( )
virtual

Destructor.

Member Function Documentation

◆ clearTxQueue()

void kanzi::connect::ClientSocketConnectionAdapter::clearTxQueue ( )
protected

Clears the transmit queue.

◆ configure()

virtual bool kanzi::connect::ClientSocketConnectionAdapter::configure ( const ClientConnectionAdapter::Parameters parameters)
virtual

◆ connect()

virtual bool kanzi::connect::ClientSocketConnectionAdapter::connect ( )
virtual

See ConnectionAdapter::connect.

Implements kanzi::connect::ClientConnectionAdapter.

◆ discardFromTxQueue()

void kanzi::connect::ClientSocketConnectionAdapter::discardFromTxQueue ( size_t  bytes)
protected

Discards data (after being sent) from tx queue.

Parameters
bytesamount of data to discard.

◆ disconnect()

virtual void kanzi::connect::ClientSocketConnectionAdapter::disconnect ( )
virtual

◆ getState()

virtual string kanzi::connect::ClientSocketConnectionAdapter::getState ( const string &  parameter)
virtual

See ConnectionAdapter::getState.

Implements kanzi::connect::ClientConnectionAdapter.

◆ hasPendingTxSocketData()

virtual bool kanzi::connect::ClientSocketConnectionAdapter::hasPendingTxSocketData ( )
inlineprotectedvirtual

Determine whether the client implementation has pending data to write.

Returns
true if there is pending data to write and socket should be listened for write availability also.

◆ interrupt()

virtual void kanzi::connect::ClientSocketConnectionAdapter::interrupt ( )
virtual

◆ queueTxData()

bool kanzi::connect::ClientSocketConnectionAdapter::queueTxData ( const vector< char > &  data,
size_t  maxQueueDepth,
size_t  position = 0 
)
protected

Tries to queue given buffer to tx queue.

Parameters
datathe data to queue
maxQueueDepththe maximum allowed depth for the queue
positionfrom the data vector, at which position to start inserting data to queue. optional.
Returns
true if queued successfully, false if not fit or other problems faced.

◆ read()

virtual void kanzi::connect::ClientSocketConnectionAdapter::read ( )
protectedpure virtual

Do the reading from socket.

◆ sendPendingTxSocketData()

virtual void kanzi::connect::ClientSocketConnectionAdapter::sendPendingTxSocketData ( )
inlineprotectedvirtual

Write pending data into the socket.

◆ wait()

virtual int kanzi::connect::ClientSocketConnectionAdapter::wait ( )
virtual

◆ work()

virtual void kanzi::connect::ClientSocketConnectionAdapter::work ( int  status)
virtual

Member Data Documentation

◆ m_mutex

recursive_mutex kanzi::connect::ClientSocketConnectionAdapter::m_mutex
protected

◆ m_port

int kanzi::connect::ClientSocketConnectionAdapter::m_port
protected

Configured server port.

◆ m_server

string kanzi::connect::ClientSocketConnectionAdapter::m_server
protected

Configured server address.

◆ m_set

::fd_set* kanzi::connect::ClientSocketConnectionAdapter::m_set
protected

Activated sockets during wait.

◆ m_signal

int kanzi::connect::ClientSocketConnectionAdapter::m_signal[2]
protected

◆ m_socket

Socket* kanzi::connect::ClientSocketConnectionAdapter::m_socket
protected

Socket used by this adapter.

◆ m_socketType

int kanzi::connect::ClientSocketConnectionAdapter::m_socketType
protected

Socket type.

◆ m_txBuffer

vector<char> kanzi::connect::ClientSocketConnectionAdapter::m_txBuffer
protected

◆ m_workResult

int kanzi::connect::ClientSocketConnectionAdapter::m_workResult
protected

Result of wait is stored here.

◆ m_writeSet

::fd_set* kanzi::connect::ClientSocketConnectionAdapter::m_writeSet
protected

◆ PARAMETER_HOST_IP

const string kanzi::connect::ClientSocketConnectionAdapter::PARAMETER_HOST_IP
static

Configuration parameter for server ip address.

◆ PARAMETER_HOST_PORT

const string kanzi::connect::ClientSocketConnectionAdapter::PARAMETER_HOST_PORT
static

Configuration parameter for server port.

◆ STATE_IP

const string kanzi::connect::ClientSocketConnectionAdapter::STATE_IP
static

State parameter to read adapter ip address back.

◆ STATE_PORT

const string kanzi::connect::ClientSocketConnectionAdapter::STATE_PORT
static

State parameter to read adapter port back.


The documentation for this class was generated from the following file: