F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Drv::TcpClientSocket Class Reference

Helper for setting up Tcp using Berkeley sockets as a client. More...

#include <Drv/Ip/TcpClientSocket.hpp>

Inheritance diagram for Drv::TcpClientSocket:
Drv::IpSocket

Public Member Functions

 TcpClientSocket ()
 Constructor for client socket tcp implementation. 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

bool isValidPort (U16 port) override
 Check if the given port is valid for the socket. More...
 
SocketIpStatus openProtocol (SocketDescriptor &socketDescriptor) override
 Tcp specific implementation for opening a client socket. 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
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...
 

Detailed Description

Helper for setting up Tcp using Berkeley sockets as a client.

Certain IP headers have conflicting definitions with the m_data member of various types in fprime. TcpClientSocket separates the ip setup from the incoming Fw::Buffer in the primary component class preventing this collision.

Definition at line 26 of file TcpClientSocket.hpp.

Constructor & Destructor Documentation

◆ TcpClientSocket()

Drv::TcpClientSocket::TcpClientSocket ( )

Constructor for client socket tcp implementation.

Definition at line 43 of file TcpClientSocket.cpp.

Member Function Documentation

◆ isValidPort()

bool Drv::TcpClientSocket::isValidPort ( U16  port)
overrideprotectedvirtual

Check if the given port is valid for the socket.

Some ports should be allowed for sockets and disabled on others (e.g. port 0 is a valid tcp server port but not a client. This will check the port and return "true" if the port is valid, or "false" otherwise. In the tcp client implementation, all ports are considered valid except for "0".

Parameters
portport to check
Returns
true if valid, false otherwise

Reimplemented from Drv::IpSocket.

Definition at line 45 of file TcpClientSocket.cpp.

◆ openProtocol()

SocketIpStatus Drv::TcpClientSocket::openProtocol ( SocketDescriptor socketDescriptor)
overrideprotectedvirtual

Tcp specific implementation for opening a client socket.

Parameters
socketDescriptor(output) descriptor opened. Only valid on SOCK_SUCCESS. Otherwise will be invalid
Returns
status of open

Implements Drv::IpSocket.

Definition at line 50 of file TcpClientSocket.cpp.

◆ recvProtocol()

I32 Drv::TcpClientSocket::recvProtocol ( const SocketDescriptor socketDescriptor,
U8 *const  data,
const U32  size 
)
overrideprotectedvirtual

Protocol specific implementation of recv. Called directly with error handling from recv.

Parameters
socketDescriptordescriptor to recv from
datadata pointer to fill
sizesize of data buffer
Returns
: size of data received, or -1 on error.

Implements Drv::IpSocket.

Definition at line 93 of file TcpClientSocket.cpp.

◆ sendProtocol()

I32 Drv::TcpClientSocket::sendProtocol ( const SocketDescriptor socketDescriptor,
const U8 *const  data,
const U32  size 
)
overrideprotectedvirtual

Protocol specific implementation of send. Called directly with retry from send.

Parameters
socketDescriptordescriptor to send to
datadata to send
sizesize of data to send
Returns
: size of data sent, or -1 on error.

Implements Drv::IpSocket.

Definition at line 89 of file TcpClientSocket.cpp.


The documentation for this class was generated from the following files: