F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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>
21
22namespace Drv {
23
25 public:
26 // ----------------------------------------------------------------------
27 // Construction, initialization, and destruction
28 // ----------------------------------------------------------------------
29
34 TcpServerComponentImpl(const char* const compName);
35
40
41 // ----------------------------------------------------------------------
42 // Helper methods to start and stop socket
43 // ----------------------------------------------------------------------
44
61 SocketIpStatus configure(const char* hostname,
62 const U16 port,
63 const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
64 const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS,
65 FwSizeType buffer_size = 1024);
66
70 bool isStarted();
71
79
85 void terminate();
86
95 U16 getListenPort();
96
97 PROTECTED:
98 // ----------------------------------------------------------------------
99 // Implementations for socket read task virtual methods
100 // ----------------------------------------------------------------------
101
110 IpSocket& getSocketHandler() override;
111
120 Fw::Buffer getBuffer() override;
121
130 void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override;
131
135 void connected() override;
136
140 void readLoop() override;
141
142 PRIVATE:
143
144 // ----------------------------------------------------------------------
145 // Handler implementations for user-defined typed input ports
146 // ----------------------------------------------------------------------
147
163 Drv::SendStatus send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer) override;
164
165 Drv::TcpServerSocket m_socket;
166
167 FwSizeType m_allocation_size;
168};
169
170} // end namespace Drv
171
172#endif // end TcpServerComponentImpl
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:55
PlatformSizeType FwSizeType
Definition FpConfig.h:35
@ SOCKET_SEND_TIMEOUT_SECONDS
Definition IpCfg.hpp:17
@ SOCKET_SEND_TIMEOUT_MICROSECONDS
Definition IpCfg.hpp:18
Helper base-class for setting up Berkeley sockets.
Definition IpSocket.hpp:55
Status returned by the send call.
supports a task to read a given socket adaptation
Auto-generated base for TcpServer component.
~TcpServerComponentImpl()
Destroy the component.
SocketIpStatus startup()
startup the server socket for communications
void connected() override
called when the IPv4 system has been connected
U16 getListenPort()
get the port being listened on
void terminate()
terminate the server socket
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, FwSizeType buffer_size=1024)
Configures the TcpServer settings but does not open the connection.
IpSocket & getSocketHandler() override
returns a reference to the socket handler
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override
sends a buffer to be filled with data
void readLoop() override
read from the socket, overridden to start and terminate the server socket
Fw::Buffer getBuffer() override
returns a buffer to fill with data
Helper for setting up Tcp using Berkeley sockets as a server.
SocketIpStatus
Status enumeration for socket return values.
Definition IpSocket.hpp:29