eRPC API Reference  Rev. 1.12.0
NXP Semiconductors
erpc_tcp_transport.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  * All rights reserved.
5  *
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  */
9 #ifndef _EMBEDDED_RPC__TCP_TRANSPORT_H_
10 #define _EMBEDDED_RPC__TCP_TRANSPORT_H_
11 
12 #if defined(__MINGW32__)
13 #include <winsock2.h>
14 #endif
15 
17 #include "erpc_threading.h"
18 
25 // Classes
28 
29 namespace erpc {
36 {
37 public:
45  explicit TCPTransport(bool isServer);
46 
56  TCPTransport(const char *host, uint16_t port, bool isServer);
57 
61  virtual ~TCPTransport(void);
62 
69  void configure(const char *host, uint16_t port);
70 
78  virtual erpc_status_t open(void);
79 
86  virtual erpc_status_t close(bool stopServer = true);
87 
88 protected:
89  bool m_isServer;
90  const char *m_host;
91  uint16_t m_port;
92 #if defined(__MINGW32__)
93  SOCKET m_socket;
94 #else
95  int m_socket;
96 #endif
98  bool m_runServer;
102 
109  virtual erpc_status_t connectClient(void);
110 
121  virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size) override;
122 
133  virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size) override;
134 
138  void serverThread(void);
139 
149  static void serverThreadStub(void *arg);
150 };
151 
152 } // namespace erpc
153 
156 #endif // _EMBEDDED_RPC__TCP_TRANSPORT_H_
static void serverThreadStub(void *arg)
Thread entry point.
Definition: erpc_tcp_transport.cpp:513
void serverThread(void)
Server thread function.
Definition: erpc_tcp_transport.cpp:405
Base class for framed transport layers.
Definition: erpc_framed_transport.hpp:56
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:106
enum _erpc_status erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:85
bool m_isServer
Definition: erpc_tcp_transport.hpp:89
Simple thread class.
Definition: erpc_threading.h:69
uint16_t m_port
Definition: erpc_tcp_transport.hpp:91
int m_socket
Definition: erpc_tcp_transport.hpp:95
virtual erpc_status_t underlyingReceive(MessageBuffer *message, uint32_t size, uint32_t offset)
Adds ability to framed transport to overwrite MessageBuffer when receiving data.
Definition: erpc_framed_transport.cpp:177
virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size) override
This function read data.
Definition: erpc_tcp_transport.cpp:306
Thread m_serverThread
Definition: erpc_tcp_transport.hpp:97
virtual ~TCPTransport(void)
TCPTransport destructor.
Definition: erpc_tcp_transport.cpp:98
Definition: erpc_arbitrated_client_manager.hpp:25
virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size) override
This function writes data.
Definition: erpc_tcp_transport.cpp:356
const char * m_host
Definition: erpc_tcp_transport.hpp:90
bool m_runServer
Definition: erpc_tcp_transport.hpp:98
TCPTransport(bool isServer)
Constructor.
Definition: erpc_tcp_transport.cpp:62
virtual erpc_status_t close(bool stopServer=true)
This function disconnects client or stop server host.
Definition: erpc_tcp_transport.cpp:282
virtual erpc_status_t connectClient(void)
This function connect client to the server.
Definition: erpc_tcp_transport.cpp:124
virtual erpc_status_t underlyingSend(MessageBuffer *message, uint32_t size, uint32_t offset)
Adds ability to framed transport to overwrite MessageBuffer when sending data.
Definition: erpc_framed_transport.cpp:170
void configure(const char *host, uint16_t port)
This function set host and port of this transport layer.
Definition: erpc_tcp_transport.cpp:100
Client side of TCP/IP transport.
Definition: erpc_tcp_transport.hpp:35