F´ Flight Software - C/C++ Documentation NASA-v1.6.0
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>
20#include "Drv/ByteStreamDriverModel/ByteStreamDriverModelComponentAc.hpp"
21
22namespace Drv {
23
24class 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
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
~TcpServerComponentImpl()
Destroy the component.
SocketIpStatus startup()
startup the TcpServer
void init(const NATIVE_INT_TYPE instance=0)
Initialize this component.
Fw::Buffer getBuffer()
returns a buffer to fill with data
void shutdown()
shutdown the TcpServer
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status)
sends a buffer to be filled with data
IpSocket & getSocketHandler()
returns a reference to the socket handler
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.
void connected()
called when the IPv4 system has been connected
Helper for setting up Tcp using Berkley sockets as a server.
SocketIpStatus
Status enumeration for socket return values.
Definition IpSocket.hpp:23