eRPC API Reference
Rev. 1.12.0
NXP Semiconductors
|
Client side of TCP/IP transport. More...
#include <erpc_tcp_transport.hpp>
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 Crc16 * | getCrc16 (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 | |
Crc16 * | m_crcImpl |
Mutex | m_sendLock |
Mutex protecting send. | |
Mutex | m_receiveLock |
Mutex protecting receive. | |
Client side of TCP/IP transport.
|
explicit |
Constructor.
This function initializes object attributes.
[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.
[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. |
void TCPTransport::configure | ( | const char * | host, |
uint16_t | port | ||
) |
This function set host and port of this transport layer.
[in] | host | Specify the host name or IP address of the computer. |
[in] | port | Specify the listening port number. |
|
virtual |
This function will create host on server side, or connect client to the server.
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. |
|
virtual |
This function disconnects client or stop server host.
[in] | stopServer | Specify is server shall be closed as well (stop listen()) |
kErpcStatus_Success | Always return this. |
|
protectedvirtual |
This function connect client to the server.
kErpcStatus_Success | When client connected successfully. |
kErpcStatus_Fail | When client doesn't connected successfully. |
|
overrideprotectedvirtual |
This function read data.
[in,out] | data | Preallocated buffer for receiving data. |
[in] | size | Size of data to read. |
kErpcStatus_Success | When data was read successfully. |
kErpcStatus_ReceiveFailed | When reading data ends with error. |
kErpcStatus_ConnectionClosed | Peer closed the connection. |
Implements erpc::FramedTransport.
|
overrideprotectedvirtual |
This function writes data.
[in] | data | Buffer to send. |
[in] | size | Size of data to send. |
kErpcStatus_Success | When data was written successfully. |
kErpcStatus_SendFailed | When writing data ends with error. |
kErpcStatus_ConnectionClosed | Peer closed the connection. |
Implements erpc::FramedTransport.
|
staticprotected |
Thread entry point.
Control is passed to the serverThread() method of the TCPTransport instance pointed to by the arg
parameter.
arg | Thread argument. The pointer to the TCPTransport instance is passed through this argument. |
|
protected |
If true then server is using transport, else client.
|
protected |
Specify the host name or IP address of the computer.
|
protected |
Specify the listening port number.
|
protected |
Socket number.
|
protected |
Pointer to server thread.
|
protected |
Thread is executed while this is true.