F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
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>
19 #include "Drv/ByteStreamDriverModel/ByteStreamDriverModelComponentAc.hpp"
20 
21 namespace Drv {
22 
23 class TcpClientComponentImpl : public ByteStreamDriverModelComponentBase, public SocketReadTask {
24  public:
25  // ----------------------------------------------------------------------
26  // Construction, initialization, and destruction
27  // ----------------------------------------------------------------------
28 
33  TcpClientComponentImpl(const char* const compName);
34 
35 
40  void init(const NATIVE_INT_TYPE instance = 0);
41 
46 
47  // ----------------------------------------------------------------------
48  // Helper methods to start and stop socket
49  // ----------------------------------------------------------------------
50 
66  SocketIpStatus configure(const char* hostname,
67  const U16 port,
68  const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
69  const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS);
70 
71  PROTECTED:
72  // ----------------------------------------------------------------------
73  // Implementations for socket read task virtual methods
74  // ----------------------------------------------------------------------
75 
85 
95 
104  void sendBuffer(Fw::Buffer buffer, SocketIpStatus status);
105 
109  void connected();
110 
111 
112  PRIVATE:
113 
114  // ----------------------------------------------------------------------
115  // Handler implementations for user-defined typed input ports
116  // ----------------------------------------------------------------------
117 
133  Drv::SendStatus send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
134 
140  Drv::PollStatus poll_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
141 
142  Drv::TcpClientSocket m_socket;
143 };
144 
145 } // end namespace Drv
146 
147 #endif // end TcpClientComponentImpl
SocketReadTask.hpp
Drv::TcpClientComponentImpl::sendBuffer
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status)
sends a buffer to be filled with data
Definition: TcpClientComponentImpl.cpp:53
Drv::IpSocket
Helper base-class for setting up Berkley sockets.
Definition: IpSocket.hpp:45
Drv::TcpClientComponentImpl
Definition: TcpClientComponentImpl.hpp:23
Drv
Definition: BlockDriver.hpp:11
Drv::TcpClientComponentImpl::init
void init(const NATIVE_INT_TYPE instance=0)
Initialize this component.
Definition: TcpClientComponentImpl.cpp:28
SOCKET_SEND_TIMEOUT_MICROSECONDS
@ SOCKET_SEND_TIMEOUT_MICROSECONDS
Definition: IpCfg.hpp:18
Fw::Buffer
Definition: Buffer.hpp:43
SOCKET_SEND_TIMEOUT_SECONDS
@ SOCKET_SEND_TIMEOUT_SECONDS
Definition: IpCfg.hpp:17
Drv::TcpClientComponentImpl::getSocketHandler
IpSocket & getSocketHandler()
returns a reference to the socket handler
Definition: TcpClientComponentImpl.cpp:45
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:27
Drv::TcpClientSocket
Helper for setting up Tcp using Berkley sockets as a client.
Definition: TcpClientSocket.hpp:26
Drv::TcpClientComponentImpl::connected
void connected()
called when the IPv4 system has been connected
Definition: TcpClientComponentImpl.cpp:58
Drv::SocketReadTask
supports a task to read a given socket adaptation
Definition: SocketReadTask.hpp:27
Drv::TcpClientComponentImpl::~TcpClientComponentImpl
~TcpClientComponentImpl()
Destroy the component.
Definition: TcpClientComponentImpl.cpp:39
TcpClientSocket.hpp
Drv::TcpClientComponentImpl::getBuffer
Fw::Buffer getBuffer()
returns a buffer to fill with data
Definition: TcpClientComponentImpl.cpp:49
Drv::TcpClientComponentImpl::TcpClientComponentImpl
TcpClientComponentImpl(const char *const compName)
construct the TcpClient component.
Definition: TcpClientComponentImpl.cpp:24
Drv::SocketIpStatus
SocketIpStatus
Status enumeration for socket return values.
Definition: IpSocket.hpp:23
Drv::TcpClientComponentImpl::configure
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.
Definition: TcpClientComponentImpl.cpp:32
IpSocket.hpp