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
TcpServerComponentImpl.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TcpServerComponentImpl.hpp
3 // \author mstarch
4 // \brief hpp file for TcpServerComponentImpl 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 TcpServerComponentImpl_HPP
14 #define TcpServerComponentImpl_HPP
15 
16 #include <IpCfg.hpp>
17 #include <Drv/Ip/IpSocket.hpp>
20 #include "Drv/ByteStreamDriverModel/ByteStreamDriverComponentAc.hpp"
21 
22 namespace Drv {
23 
24 class TcpServerComponentImpl : public ByteStreamDriverModelComponentBase, public SocketReadTask {
25  public:
26  // ----------------------------------------------------------------------
27  // Construction, initialization, and destruction
28  // ----------------------------------------------------------------------
29 
34  TcpServerComponentImpl(const char* const compName);
35 
36 
41  void init(const NATIVE_INT_TYPE instance = 0);
42 
47 
48  // ----------------------------------------------------------------------
49  // Helper methods to start and stop socket
50  // ----------------------------------------------------------------------
51 
67  SocketIpStatus configure(const char* hostname,
68  const U16 port,
69  const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
70  const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS);
82 
89  void shutdown();
90 
91  PROTECTED:
92  // ----------------------------------------------------------------------
93  // Implementations for socket read task virtual methods
94  // ----------------------------------------------------------------------
95 
105 
115 
124  void sendBuffer(Fw::Buffer buffer, SocketIpStatus status);
125 
126  PRIVATE:
127 
128  // ----------------------------------------------------------------------
129  // Handler implementations for user-defined typed input ports
130  // ----------------------------------------------------------------------
131 
147  Drv::SendStatus send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
148 
154  Drv::PollStatus poll_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
155 
156  Drv::TcpServerSocket m_socket;
157 };
158 
159 } // end namespace Drv
160 
161 #endif // end TcpServerComponentImpl
Drv::TcpServerComponentImpl::TcpServerComponentImpl
TcpServerComponentImpl(const char *const compName)
construct the TcpClient component.
Definition: TcpServerComponentImpl.cpp:22
SocketReadTask.hpp
Drv::TcpServerComponentImpl::getBuffer
Fw::Buffer getBuffer()
returns a buffer to fill with data
Definition: TcpServerComponentImpl.cpp:55
Drv::IpSocket
Helper base-class for setting up Berkley sockets.
Definition: IpSocket.hpp:45
Drv
Definition: BlockDriverImpl.cpp:5
IpCfg.hpp
Drv::TcpServerComponentImpl::shutdown
void shutdown()
shutdown the TcpServer
Definition: TcpServerComponentImpl.cpp:43
SOCKET_SEND_TIMEOUT_MICROSECONDS
@ SOCKET_SEND_TIMEOUT_MICROSECONDS
Definition: IpCfg.hpp:18
Drv::TcpServerComponentImpl::getSocketHandler
IpSocket & getSocketHandler()
returns a reference to the socket handler
Definition: TcpServerComponentImpl.cpp:51
Drv::TcpServerComponentImpl::~TcpServerComponentImpl
~TcpServerComponentImpl(void)
Destroy the component.
Definition: TcpServerComponentImpl.cpp:37
Fw::Buffer
Definition: Buffer.hpp:43
Drv::TcpServerComponentImpl
Definition: TcpServerComponentImpl.hpp:24
SOCKET_SEND_TIMEOUT_SECONDS
@ SOCKET_SEND_TIMEOUT_SECONDS
Definition: IpCfg.hpp:17
Drv::TcpServerComponentImpl::sendBuffer
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status)
sends a buffer to filled with data
Definition: TcpServerComponentImpl.cpp:59
Drv::TcpServerComponentImpl::startup
SocketIpStatus startup()
startup the TcpServer
Definition: TcpServerComponentImpl.cpp:39
Drv::TcpServerComponentImpl::init
void init(const NATIVE_INT_TYPE instance=0)
Initialize this component.
Definition: TcpServerComponentImpl.cpp:26
Drv::SocketReadTask
supports a task to read a given socket adaptation
Definition: SocketReadTask.hpp:27
Drv::TcpServerSocket
Helper for setting up Tcp using Berkley sockets as a server.
Definition: TcpServerSocket.hpp:26
Drv::SocketIpStatus
SocketIpStatus
Status enumeration for socket return values.
Definition: IpSocket.hpp:23
TcpServerSocket.hpp
Drv::TcpServerComponentImpl::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: TcpServerComponentImpl.cpp:30
IpSocket.hpp
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29