eRPC API Reference  Rev. 1.12.0
NXP Semiconductors
erpc::TCPTransport Class Reference

Client side of TCP/IP transport. More...

#include <erpc_tcp_transport.hpp>

+ Inheritance diagram for erpc::TCPTransport:
+ Collaboration diagram for erpc::TCPTransport:

Public Member Functions

 TCPTransport (bool isServer)
 Constructor. More...
 
 TCPTransport (const char *host, uint16_t port, bool isServer)
 Constructor. More...
 
virtual ~TCPTransport (void)
 TCPTransport destructor.
 
void configure (const char *host, uint16_t port)
 This function set host and port of this transport layer. More...
 
virtual erpc_status_t open (void)
 This function will create host on server side, or connect client to the server. More...
 
virtual erpc_status_t close (bool stopServer=true)
 This function disconnects client or stop server host. More...
 
- Public Member Functions inherited from erpc::FramedTransport
 FramedTransport (void)
 Constructor.
 
virtual ~FramedTransport (void)
 FramedTransport destructor.
 
virtual uint8_t reserveHeaderSize (void) override
 Size of data placed in MessageBuffer before serializing eRPC data. More...
 
virtual erpc_status_t receive (MessageBuffer *message) override
 Receives an entire message. More...
 
virtual erpc_status_t send (MessageBuffer *message) override
 Function to send prepared message. More...
 
virtual void setCrc16 (Crc16 *crcImpl) override
 This functions sets the CRC-16 implementation. More...
 
virtual Crc16getCrc16 (void) override
 This functions gets the CRC-16 object. More...
 
- Public Member Functions inherited from erpc::Transport
 Transport (void)
 Constructor.
 
virtual ~Transport (void)
 Transport destructor.
 
virtual bool hasMessage (void)
 Poll for an incoming message. More...
 

Protected Member Functions

virtual erpc_status_t connectClient (void)
 This function connect client to the server. More...
 
virtual erpc_status_t underlyingReceive (uint8_t *data, uint32_t size) override
 This function read data. More...
 
virtual erpc_status_t underlyingSend (const uint8_t *data, uint32_t size) override
 This function writes data. More...
 
void serverThread (void)
 Server thread function.
 
- Protected Member Functions inherited from erpc::FramedTransport
virtual erpc_status_t underlyingSend (MessageBuffer *message, uint32_t size, uint32_t offset)
 Adds ability to framed transport to overwrite MessageBuffer when sending data. More...
 
virtual erpc_status_t underlyingReceive (MessageBuffer *message, uint32_t size, uint32_t offset)
 Adds ability to framed transport to overwrite MessageBuffer when receiving data. More...
 

Static Protected Member Functions

static void serverThreadStub (void *arg)
 Thread entry point. More...
 

Protected Attributes

bool m_isServer
 
const char * m_host
 
uint16_t m_port
 
int m_socket
 
Thread m_serverThread
 
bool m_runServer
 
- Protected Attributes inherited from erpc::FramedTransport
Crc16m_crcImpl
 
Mutex m_sendLock
 Mutex protecting send.
 
Mutex m_receiveLock
 Mutex protecting receive.
 

Detailed Description

Client side of TCP/IP transport.

Constructor & Destructor Documentation

TCPTransport::TCPTransport ( bool  isServer)
explicit

Constructor.

This function initializes object attributes.

Parameters
[in]isServerTrue when this transport is used for server side application.
TCPTransport::TCPTransport ( const char *  host,
uint16_t  port,
bool  isServer 
)

Constructor.

This function initializes object attributes.

Parameters
[in]hostSpecify the host name or IP address of the computer.
[in]portSpecify the listening port number.
[in]isServerTrue when this transport is used for server side application.

Member Function Documentation

void TCPTransport::configure ( const char *  host,
uint16_t  port 
)

This function set host and port of this transport layer.

Parameters
[in]hostSpecify the host name or IP address of the computer.
[in]portSpecify the listening port number.
erpc_status_t TCPTransport::open ( void  )
virtual

This function will create host on server side, or connect client to the server.

Return values
kErpcStatus_SuccessWhen creating host was successful or client connected successfully.
kErpcStatus_UnknownNameHost name resolution failed.
kErpcStatus_ConnectionFailureConnecting to the specified host failed.
erpc_status_t TCPTransport::close ( bool  stopServer = true)
virtual

This function disconnects client or stop server host.

Parameters
[in]stopServerSpecify is server shall be closed as well (stop listen())
Return values
kErpcStatus_SuccessAlways return this.
erpc_status_t TCPTransport::connectClient ( void  )
protectedvirtual

This function connect client to the server.

Return values
kErpcStatus_SuccessWhen client connected successfully.
kErpcStatus_FailWhen client doesn't connected successfully.
erpc_status_t TCPTransport::underlyingReceive ( uint8_t *  data,
uint32_t  size 
)
overrideprotectedvirtual

This function read data.

Parameters
[in,out]dataPreallocated buffer for receiving data.
[in]sizeSize of data to read.
Return values
kErpcStatus_SuccessWhen data was read successfully.
kErpcStatus_ReceiveFailedWhen reading data ends with error.
kErpcStatus_ConnectionClosedPeer closed the connection.

Implements erpc::FramedTransport.

erpc_status_t TCPTransport::underlyingSend ( const uint8_t *  data,
uint32_t  size 
)
overrideprotectedvirtual

This function writes data.

Parameters
[in]dataBuffer to send.
[in]sizeSize of data to send.
Return values
kErpcStatus_SuccessWhen data was written successfully.
kErpcStatus_SendFailedWhen writing data ends with error.
kErpcStatus_ConnectionClosedPeer closed the connection.

Implements erpc::FramedTransport.

void TCPTransport::serverThreadStub ( void *  arg)
staticprotected

Thread entry point.

Control is passed to the serverThread() method of the TCPTransport instance pointed to by the arg parameter.

Parameters
argThread argument. The pointer to the TCPTransport instance is passed through this argument.

Member Data Documentation

bool erpc::TCPTransport::m_isServer
protected

If true then server is using transport, else client.

const char* erpc::TCPTransport::m_host
protected

Specify the host name or IP address of the computer.

uint16_t erpc::TCPTransport::m_port
protected

Specify the listening port number.

int erpc::TCPTransport::m_socket
protected

Socket number.

Thread erpc::TCPTransport::m_serverThread
protected

Pointer to server thread.

bool erpc::TCPTransport::m_runServer
protected

Thread is executed while this is true.


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