eRPC API Reference  Rev. 1.7.0
NXP Semiconductors
erpc_tcp_transport.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015, Freescale Semiconductor, Inc.
4  * Copyright 2016 NXP
5  * All rights reserved.
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted (subject to the limitations in the disclaimer below) provided
10  * that the following conditions are met:
11  *
12  * o Redistributions of source code must retain the above copyright notice, this list
13  * of conditions and the following disclaimer.
14  *
15  * o Redistributions in binary form must reproduce the above copyright notice, this
16  * list of conditions and the following disclaimer in the documentation and/or
17  * other materials provided with the distribution.
18  *
19  * o Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 #ifndef _EMBEDDED_RPC__TCP_TRANSPORT_H_
36 #define _EMBEDDED_RPC__TCP_TRANSPORT_H_
37 
38 #include "erpc_framed_transport.h"
39 #include "erpc_threading.h"
40 
47 // Classes
50 
51 namespace erpc {
58 {
59 public:
67  TCPTransport(bool isServer);
68 
78  TCPTransport(const char *host, uint16_t port, bool isServer);
79 
83  virtual ~TCPTransport(void);
84 
91  void configure(const char *host, uint16_t port);
92 
100  virtual erpc_status_t open(void);
101 
107  virtual erpc_status_t close(void);
108 
109 protected:
110  bool m_isServer;
111  const char *m_host;
112  uint16_t m_port;
113  int m_socket;
115  bool m_runServer;
123  virtual erpc_status_t connectClient(void);
124 
135  virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size);
136 
147  virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size);
148 
152  void serverThread(void);
153 
163  static void serverThreadStub(void *arg);
164 };
165 
166 } // namespace erpc
167 
170 #endif // _EMBEDDED_RPC__TCP_TRANSPORT_H_
int32_t erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:112
static void serverThreadStub(void *arg)
Thread entry point.
Definition: erpc_tcp_transport.cpp:342
void serverThread(void)
Server thread function.
Definition: erpc_tcp_transport.cpp:274
Base class for framed transport layers.
Definition: erpc_framed_transport.h:80
virtual erpc_status_t open(void)
This function will create host on server side, or connect client to the server.
Definition: erpc_tcp_transport.cpp:92
virtual erpc_status_t close(void)
This function disconnects client or stop server host.
Definition: erpc_tcp_transport.cpp:191
bool m_isServer
Definition: erpc_tcp_transport.h:110
Simple thread class.
Definition: erpc_threading.h:82
uint16_t m_port
Definition: erpc_tcp_transport.h:112
int m_socket
Definition: erpc_tcp_transport.h:113
Thread m_serverThread
Definition: erpc_tcp_transport.h:114
virtual ~TCPTransport(void)
TCPTransport destructor.
Definition: erpc_tcp_transport.cpp:84
Definition: erpc_arbitrated_client_manager.h:51
const char * m_host
Definition: erpc_tcp_transport.h:111
virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size)
This function writes data.
Definition: erpc_tcp_transport.cpp:243
bool m_runServer
Definition: erpc_tcp_transport.h:115
TCPTransport(bool isServer)
Constructor.
Definition: erpc_tcp_transport.cpp:64
virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size)
This function read data.
Definition: erpc_tcp_transport.cpp:207
virtual erpc_status_t connectClient(void)
This function connect client to the server.
Definition: erpc_tcp_transport.cpp:106
void configure(const char *host, uint16_t port)
This function set host and port of this transport layer.
Definition: erpc_tcp_transport.cpp:86
Client side of TCP/IP transport.
Definition: erpc_tcp_transport.h:57