F´ Flight Software - C/C++ Documentation  devel
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  public:
25  // ----------------------------------------------------------------------
26  // Construction, initialization, and destruction
27  // ----------------------------------------------------------------------
28 
33  TcpClientComponentImpl(const char* const compName);
34 
39 
40  // ----------------------------------------------------------------------
41  // Helper methods to start and stop socket
42  // ----------------------------------------------------------------------
43 
59  SocketIpStatus configure(const char* hostname,
60  const U16 port,
61  const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
62  const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS);
63 
64  PROTECTED:
65  // ----------------------------------------------------------------------
66  // Implementations for socket read task virtual methods
67  // ----------------------------------------------------------------------
68 
78 
88 
97  void sendBuffer(Fw::Buffer buffer, SocketIpStatus status);
98 
102  void connected();
103 
104 
105  PRIVATE:
106 
107  // ----------------------------------------------------------------------
108  // Handler implementations for user-defined typed input ports
109  // ----------------------------------------------------------------------
110 
126  Drv::SendStatus send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
127 
128  Drv::TcpClientSocket m_socket;
129 };
130 
131 } // end namespace Drv
132 
133 #endif // end TcpClientComponentImpl
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
@ SOCKET_SEND_TIMEOUT_SECONDS
Definition: IpCfg.hpp:17
@ SOCKET_SEND_TIMEOUT_MICROSECONDS
Definition: IpCfg.hpp:18
Helper base-class for setting up Berkeley sockets.
Definition: IpSocket.hpp:46
Status returned by the send call.
supports a task to read a given socket adaptation
Auto-generated base for TcpClient component.
TcpClientComponentImpl(const char *const compName)
construct the TcpClient component.
void connected()
called when the IPv4 system has been connected
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status)
sends a buffer to be filled with data
IpSocket & getSocketHandler()
returns a reference to the socket handler
Fw::Buffer getBuffer()
returns a buffer to fill with data
~TcpClientComponentImpl()
Destroy the component.
SocketIpStatus configure(const char *hostname, const U16 port, const U32 send_timeout_seconds=SOCKET_SEND_TIMEOUT_SECONDS, const U32 send_timeout_microseconds=SOCKET_SEND_TIMEOUT_MICROSECONDS)
Configures the TcpClient settings but does not open the connection.
Helper for setting up Tcp using Berkeley sockets as a client.
SocketIpStatus
Status enumeration for socket return values.
Definition: IpSocket.hpp:23