F´ Flight Software - C/C++ Documentation NASA-v1.6.0
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/ByteStreamDriverModelComponentAc.hpp"
20
21namespace Drv {
22
23class 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
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 Berkley sockets.
Definition IpSocket.hpp:45
supports a task to read a given socket adaptation
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.
void init(const NATIVE_INT_TYPE instance=0)
Initialize this 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 Berkley sockets as a client.
SocketIpStatus
Status enumeration for socket return values.
Definition IpSocket.hpp:23