F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TcpClientComponentImpl.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TcpClientComponentImpl.hpp
3 // \author mstarch
4 // \brief hpp file for TcpClientComponentImpl component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2020, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #ifndef TcpClientComponentImpl_HPP
14 #define TcpClientComponentImpl_HPP
15 
16 #include <Drv/Ip/IpSocket.hpp>
20 
21 namespace Drv {
22 
24  friend class TcpClientTester;
25 
26  public:
27  // ----------------------------------------------------------------------
28  // Construction, initialization, and destruction
29  // ----------------------------------------------------------------------
30 
35  TcpClientComponentImpl(const char* const compName);
36 
41 
42  // ----------------------------------------------------------------------
43  // Helper methods to start and stop socket
44  // ----------------------------------------------------------------------
45 
67  SocketIpStatus configure(const char* const ipv4_address,
68  const U16 port,
69  const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
70  const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS,
71  FwSizeType buffer_size = 1024);
72 
73  protected:
74  // ----------------------------------------------------------------------
75  // Implementations for socket read task virtual methods
76  // ----------------------------------------------------------------------
77 
86  IpSocket& getSocketHandler() override;
87 
96  Fw::Buffer getBuffer() override;
97 
106  void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override;
107 
111  void connected() override;
112 
113  private:
114  // ----------------------------------------------------------------------
115  // Handler implementations for user-defined typed input ports
116  // ----------------------------------------------------------------------
117 
132  Drv::ByteStreamStatus send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) override;
133 
137  void recvReturnIn_handler(FwIndexType portNum,
138  Fw::Buffer& fwBuffer
139  ) override;
140 
141  Drv::TcpClientSocket m_socket;
142 
143  // Member variable to store the buffer size
144  FwSizeType m_allocation_size;
145 };
146 
147 } // end namespace Drv
148 
149 #endif // end TcpClientComponentImpl
Fw::Buffer getBuffer() override
returns a buffer to fill with data
PlatformSizeType FwSizeType
~TcpClientComponentImpl()
Destroy the component.
Auto-generated base for TcpClient component.
TcpClientComponentImpl(const char *const compName)
construct the TcpClient component.
IpSocket & getSocketHandler() override
returns a reference to the socket handler
supports a task to read a given socket adaptation
Status returned by the send call.
void connected() override
called when the IPv4 system has been connected
PlatformIndexType FwIndexType
SocketIpStatus
Status enumeration for socket return values.
Definition: IpSocket.hpp:29
Helper base-class for setting up Berkeley sockets.
Definition: IpSocket.hpp:57
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override
sends a buffer to be filled with data
SocketIpStatus configure(const char *const ipv4_address, const U16 port, const U32 send_timeout_seconds=SOCKET_SEND_TIMEOUT_SECONDS, const U32 send_timeout_microseconds=SOCKET_SEND_TIMEOUT_MICROSECONDS, FwSizeType buffer_size=1024)
Configures the TcpClient settings but does not open the connection.
Helper for setting up Tcp using Berkeley sockets as a client.