F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
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/ByteStreamDriverModelComponentAc.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 
129  void connected();
130 
131 
132  PRIVATE:
133 
134  // ----------------------------------------------------------------------
135  // Handler implementations for user-defined typed input ports
136  // ----------------------------------------------------------------------
137 
153  Drv::SendStatus send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
154 
160  Drv::PollStatus poll_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
161 
162  Drv::TcpServerSocket m_socket;
163 };
164 
165 } // end namespace Drv
166 
167 #endif // end TcpServerComponentImpl
Drv::TcpServerComponentImpl::TcpServerComponentImpl
TcpServerComponentImpl(const char *const compName)
construct the TcpClient component.
Definition: TcpServerComponentImpl.cpp:23
Drv::TcpServerComponentImpl::~TcpServerComponentImpl
~TcpServerComponentImpl()
Destroy the component.
Definition: TcpServerComponentImpl.cpp:38
SocketReadTask.hpp
Drv::TcpServerComponentImpl::getBuffer
Fw::Buffer getBuffer()
returns a buffer to fill with data
Definition: TcpServerComponentImpl.cpp:56
Drv::IpSocket
Helper base-class for setting up Berkley sockets.
Definition: IpSocket.hpp:45
Drv
Definition: BlockDriver.hpp:11
IpCfg.hpp
Drv::TcpServerComponentImpl::shutdown
void shutdown()
shutdown the TcpServer
Definition: TcpServerComponentImpl.cpp:44
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:52
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 be filled with data
Definition: TcpServerComponentImpl.cpp:60
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:27
Drv::TcpServerComponentImpl::startup
SocketIpStatus startup()
startup the TcpServer
Definition: TcpServerComponentImpl.cpp:40
Drv::TcpServerComponentImpl::init
void init(const NATIVE_INT_TYPE instance=0)
Initialize this component.
Definition: TcpServerComponentImpl.cpp:27
Drv::TcpServerComponentImpl::connected
void connected()
called when the IPv4 system has been connected
Definition: TcpServerComponentImpl.cpp:65
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:31
IpSocket.hpp