fprime/Drv/Ip/TcpServerSocket.hpp
M Starch b76d8c9a0c
Update/types refactor as constants (#1623)
* lestarch: adding logical types implementation into Linux/StandardTypes.hpp

* lestarch: removing VxWorks StandardTypes from repository

* updated fprime types for correct compilation with vxworks and baremetal

* lestarch: refactoring types and configuration header w.r.t type design

* lestarch: replacing usages of AssertArg with FwAssertArgType

* lestarch: missspelled configuration

* lestarch: minor compilation fixes

* lestarch: renaming StandardTypes.hpp -> PlatformTypes.hpp

* lestarch: updating PRI tokens

* lestarch: replacing BasicTypes.hpp includes with FpConfig.hpp

* lestarch: UT and compilation fixes for types refactor

* lestarch: sp

* lestarch: fixing RPI issues in PassiveConsoleTextLogger

* lestarch: converting RPI build to debug

* lestarch: removing duplicate config imports

* lestarch: fixing documentation

* lestarch: fixing up multiple definitions and RPI compilation problems

* lestarch: reverting debug build

* lestarch: reverting platform types to class-based constants

* lestarch: reworking basic types

* lestarch: configured types refactor into classes

* lestarch: fixing bugs with static constants in classes

* lestarch: fixing platform types spelling and documentation

* lestarch: adding include guards to types headers

Co-authored-by: Kevin F Ortega <kevin.f.ortega@jpl.nasa.gov>
2022-08-18 13:25:56 -07:00

77 lines
2.7 KiB
C++

// ======================================================================
// \title TcpServerSocket.hpp
// \author mstarch
// \brief hpp file for TcpServerSocket core implementation classes
//
// \copyright
// Copyright 2009-2020, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================
#ifndef DRV_TCPSERVER_TCPHELPER_HPP_
#define DRV_TCPSERVER_TCPHELPER_HPP_
#include <FpConfig.hpp>
#include <Drv/Ip/IpSocket.hpp>
#include <IpCfg.hpp>
namespace Drv {
/**
* \brief Helper for setting up Tcp using Berkley sockets as a server
*
* Certain IP headers have conflicting definitions with the m_data member of various types in fprime. TcpServerSocket
* separates the ip setup from the incoming Fw::Buffer in the primary component class preventing this collision.
*/
class TcpServerSocket : public IpSocket {
public:
/**
* \brief Constructor for client socket tcp implementation
*/
TcpServerSocket();
/**
* \brief Opens the server socket and listens, does not block.
*
* Opens the server's listening socket such that this server can listen for incoming client requests. Given the
* nature of this component, only one (1) client can be handled at a time. After this call succeeds, clients may
* connect. This call does not block, block occurs on `open` while waiting to accept incoming clients.
* \return status of the server socket setup.
*/
SocketIpStatus startup();
/**
* \brief Shutdown client socket, and listening server socket
*
*
*/
void shutdown();
PROTECTED:
/**
* \brief Tcp specific implementation for opening a client socket connected to this server.
* \param fd: (output) file descriptor opened. Only valid on SOCK_SUCCESS. Otherwise will be invalid
* \return status of open
*/
SocketIpStatus openProtocol(NATIVE_INT_TYPE& fd);
/**
* \brief Protocol specific implementation of send. Called directly with retry from send.
* \param data: data to send
* \param size: size of data to send
* \return: size of data sent, or -1 on error.
*/
I32 sendProtocol(const U8* const data, const U32 size);
/**
* \brief Protocol specific implementation of recv. Called directly with error handling from recv.
* \param data: data pointer to fill
* \param size: size of data buffer
* \return: size of data received, or -1 on error.
*/
I32 recvProtocol( U8* const data, const U32 size);
private:
NATIVE_INT_TYPE m_base_fd; //!< File descriptor of the listening socket
};
} // namespace Drv
#endif /* DRV_TCPSERVER_TCPHELPER_HPP_ */