F´ Flight Software - C/C++ Documentation
devel
A framework for building embedded system applications to NASA flight quality standards.
|
Helper for setting up Tcp using Berkeley sockets as a server. More...
#include <Drv/Ip/TcpServerSocket.hpp>
Public Member Functions | |
TcpServerSocket () | |
Constructor for client socket tcp implementation. More... | |
SocketIpStatus | startup (SocketDescriptor &socketDescriptor) |
Opens the server socket and listens, does not block. More... | |
void | terminate (const SocketDescriptor &socketDescriptor) |
close the server socket created by the startup call More... | |
U16 | getListenPort () |
get the port being listened on More... | |
Public Member Functions inherited from Drv::IpSocket | |
IpSocket () | |
virtual | ~IpSocket () |
SocketIpStatus | configure (const char *hostname, const U16 port, const U32 send_timeout_seconds, const U32 send_timeout_microseconds) |
configure the ip socket with host and transmission timeouts More... | |
SocketIpStatus | open (SocketDescriptor &socketDescriptor) |
open the IP socket for communications More... | |
SocketIpStatus | send (const SocketDescriptor &socketDescriptor, const U8 *const data, const U32 size) |
send data out the IP socket from the given buffer More... | |
SocketIpStatus | recv (const SocketDescriptor &fd, U8 *const data, U32 &size) |
receive data from the IP socket from the given buffer More... | |
void | close (const SocketDescriptor &socketDescriptor) |
closes the socket More... | |
void | shutdown (const SocketDescriptor &socketDescriptor) |
shutdown the socket More... | |
Protected Member Functions | |
SocketIpStatus | openProtocol (SocketDescriptor &socketDescriptor) override |
Tcp specific implementation for opening a client socket connected to this server. More... | |
I32 | sendProtocol (const SocketDescriptor &socketDescriptor, const U8 *const data, const U32 size) override |
Protocol specific implementation of send. Called directly with retry from send. More... | |
I32 | recvProtocol (const SocketDescriptor &socketDescriptor, U8 *const data, const U32 size) override |
Protocol specific implementation of recv. Called directly with error handling from recv. More... | |
Protected Member Functions inherited from Drv::IpSocket | |
virtual bool | isValidPort (U16 port) |
Check if the given port is valid for the socket. More... | |
SocketIpStatus | setupTimeouts (PlatformIntType socketFd) |
setup the socket timeout properties of the opened outgoing socket More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Drv::IpSocket | |
static SocketIpStatus | addressToIp4 (const char *address, void *ip4) |
converts a given address in dot form x.x.x.x to an ip address. ONLY works for IPv4. More... | |
Protected Attributes inherited from Drv::IpSocket | |
U32 | m_timeoutSeconds |
U32 | m_timeoutMicroseconds |
U16 | m_port |
IP address port used. More... | |
char | m_hostname [SOCKET_MAX_HOSTNAME_SIZE] |
Hostname to supply. More... | |
Helper for setting up Tcp using Berkeley 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.
Definition at line 27 of file TcpServerSocket.hpp.
Drv::TcpServerSocket::TcpServerSocket | ( | ) |
Constructor for client socket tcp implementation.
Definition at line 41 of file TcpServerSocket.cpp.
U16 Drv::TcpServerSocket::getListenPort | ( | ) |
get the port being listened on
Most useful when listen was configured to use port "0", this will return the port used for listening after a port has been determined. Will return 0 if the connection has not been setup.
Definition at line 43 of file TcpServerSocket.cpp.
|
overrideprotectedvirtual |
Tcp specific implementation for opening a client socket connected to this server.
socketDescriptor | (output) descriptor opened. Only valid on SOCK_SUCCESS. Otherwise will be invalid |
Implements Drv::IpSocket.
Definition at line 96 of file TcpServerSocket.cpp.
|
overrideprotectedvirtual |
Protocol specific implementation of recv. Called directly with error handling from recv.
socketDescriptor | descriptor to recv from |
data | data pointer to fill |
size | size of data buffer |
Implements Drv::IpSocket.
Definition at line 125 of file TcpServerSocket.cpp.
|
overrideprotectedvirtual |
Protocol specific implementation of send. Called directly with retry from send.
socketDescriptor | descriptor to send to |
data | data to send |
size | size of data to send |
Implements Drv::IpSocket.
Definition at line 121 of file TcpServerSocket.cpp.
SocketIpStatus Drv::TcpServerSocket::startup | ( | SocketDescriptor & | socketDescriptor | ) |
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.
socketDescriptor | server descriptor will be written here |
Definition at line 48 of file TcpServerSocket.cpp.
void Drv::TcpServerSocket::terminate | ( | const SocketDescriptor & | socketDescriptor | ) |
close the server socket created by the startup
call
Calls the close function on the server socket. No shutdown is performed on the server socket, as that is left to the individual client sockets.
socketDescriptor | descriptor to close |
Definition at line 92 of file TcpServerSocket.cpp.