| eRPC API Reference Rev. 1.8.1 NXP Semiconductors

- Main Page
- API Reference
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
erpc::TCPTransport Class Reference
Transport Layers » TCP/IP

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

`#include <erpc_tcp_transport.h>`

Inheritance diagram for erpc::TCPTransport:
[legend]
Collaboration diagram for erpc::TCPTransport:
[legend]

## 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)
| Codec destructor.
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...
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)
| This function read data. More...
virtual erpc_status_t | underlyingSend (const uint8_t *data, uint32_t size)
| This function writes data. More...
void | serverThread (void)
| Server thread function.

## 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
Crc16 * | m_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 | ) |

Constructor.

This function initializes object attributes.

Parameters

  [in] | isServer | True 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] | host | Specify the host name or IP address of the computer.
  [in] | port | Specify the listening port number.
  [in] | isServer | True 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] | host | Specify the host name or IP address of the computer.
  [in] | port | Specify 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_Success | When creating host was successful or client connected successfully.
  kErpcStatus_UnknownName | Host name resolution failed.
  kErpcStatus_ConnectionFailure | Connecting to the specified host failed.

erpc_status_t TCPTransport::close | ( | bool | stopServer = `true` | ) |
| virtual

This function disconnects client or stop server host.

Parameters

  [in] | stopServer | Specify is server shall be closed as well (stop listen())

Return values

  kErpcStatus_Success | Always return this.

erpc_status_t TCPTransport::connectClient | ( | void |  | ) |
| protected virtual

This function connect client to the server.

Return values

  kErpcStatus_Success | When client connected successfully.
  kErpcStatus_Fail | When client doesn't connected successfully.

erpc_status_t TCPTransport::underlyingReceive | ( | uint8_t * | data,
|  | uint32_t | size
| ) |  |
| protected virtual

This function read data.

Parameters

  [in,out] | data | Preallocated buffer for receiving data.
  [in] | size | Size of data to read.

Return values

  kErpcStatus_Success | When data was read successfully.
  kErpcStatus_ReceiveFailed | When reading data ends with error.
  kErpcStatus_ConnectionClosed | Peer closed the connection.

Implements erpc::FramedTransport.

erpc_status_t TCPTransport::underlyingSend | ( | const uint8_t * | data,
|  | uint32_t | size
| ) |  |
| protected virtual

This function writes data.

Parameters

  [in] | data | Buffer to send.
  [in] | size | Size of data to send.

Return values

  kErpcStatus_Success | When data was written successfully.
  kErpcStatus_SendFailed | When writing data ends with error.
  kErpcStatus_ConnectionClosed | Peer closed the connection.

Implements erpc::FramedTransport.

void TCPTransport::serverThreadStub | ( | void * | arg | ) |
| static protected

Thread entry point.

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

Parameters

  arg | Thread 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:

- erpc_tcp_transport.h
- erpc_tcp_transport.cpp