F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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/ByteStreamDriverComponentAc.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 
106  PRIVATE:
107 
108  // ----------------------------------------------------------------------
109  // Handler implementations for user-defined typed input ports
110  // ----------------------------------------------------------------------
111 
127  Drv::SendStatus send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
128 
134  Drv::PollStatus poll_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
135 
136  Drv::TcpClientSocket m_socket;
137 };
138 
139 } // end namespace Drv
140 
141 #endif // end TcpClientComponentImpl
SocketReadTask.hpp
Drv::TcpClientComponentImpl::sendBuffer
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status)
sends a buffer to filled with data
Definition: TcpClientComponentImpl.cpp:52
Drv::IpSocket
Helper base-class for setting up Berkley sockets.
Definition: IpSocket.hpp:45
Drv::TcpClientComponentImpl
Definition: TcpClientComponentImpl.hpp:23
Drv
Definition: BlockDriverImpl.cpp:5
Drv::TcpClientComponentImpl::init
void init(const NATIVE_INT_TYPE instance=0)
Initialize this component.
Definition: TcpClientComponentImpl.cpp:27
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:44
Drv::TcpClientComponentImpl::~TcpClientComponentImpl
~TcpClientComponentImpl(void)
Destroy the component.
Definition: TcpClientComponentImpl.cpp:38
Drv::TcpClientSocket
Helper for setting up Tcp using Berkley sockets as a client.
Definition: TcpClientSocket.hpp:26
Drv::SocketReadTask
supports a task to read a given socket adaptation
Definition: SocketReadTask.hpp:27
TcpClientSocket.hpp
Drv::TcpClientComponentImpl::getBuffer
Fw::Buffer getBuffer()
returns a buffer to fill with data
Definition: TcpClientComponentImpl.cpp:48
Drv::TcpClientComponentImpl::TcpClientComponentImpl
TcpClientComponentImpl(const char *const compName)
construct the TcpClient component.
Definition: TcpClientComponentImpl.cpp:23
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:31
IpSocket.hpp
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29