F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
UdpSocket.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title UdpSocket.hpp
3// \author mstarch
4// \brief hpp file for UdpSocket core implementation classes
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#ifndef DRV_IP_UDPSOCKET_HPP_
13#define DRV_IP_UDPSOCKET_HPP_
14
15#include <FpConfig.hpp>
16#include <Drv/Ip/IpSocket.hpp>
17#include <IpCfg.hpp>
18
19namespace Drv {
20
21struct SocketState;
22
29class UdpSocket : public IpSocket {
30 public:
34 UdpSocket();
38 virtual ~UdpSocket();
39
57 SocketIpStatus configureSend(const char* hostname, const U16 port, const U32 send_timeout_seconds,
58 const U32 send_timeout_microseconds);
59
73 SocketIpStatus configureRecv(const char* hostname, const U16 port);
74
83 U16 getRecvPort();
84
85 PROTECTED:
86
98 SocketIpStatus openProtocol(SocketDescriptor& socketDescriptor) override;
106 I32 sendProtocol(const SocketDescriptor& socketDescriptor, const U8* const data, const U32 size) override;
114 I32 recvProtocol(const SocketDescriptor& socketDescriptor, U8* const data, const U32 size) override;
115 private:
116 SocketState* m_state;
117 U16 m_recv_port;
118 char m_recv_hostname[SOCKET_MAX_HOSTNAME_SIZE];
119};
120} // namespace Drv
121
122#endif /* DRV_IP_UDPSOCKET_HPP_ */
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:30
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
C++-compatible configuration header for fprime configuration.
@ SOCKET_MAX_HOSTNAME_SIZE
Definition IpCfg.hpp:22
Helper base-class for setting up Berkeley sockets.
Definition IpSocket.hpp:55
Helper for setting up Udp using Berkeley sockets as a client.
Definition UdpSocket.hpp:29
I32 sendProtocol(const SocketDescriptor &socketDescriptor, const U8 *const data, const U32 size) override
Protocol specific implementation of send. Called directly with retry from send.
SocketIpStatus bind(const PlatformIntType fd)
bind the UDP to a port such that it can receive packets at the previously configured port
Definition UdpSocket.cpp:83
U16 getRecvPort()
get the port being received on
Definition UdpSocket.cpp:77
UdpSocket()
Constructor for client socket udp implementation.
Definition UdpSocket.cpp:53
SocketIpStatus openProtocol(SocketDescriptor &socketDescriptor) override
udp specific implementation for opening a socket.
SocketIpStatus configureRecv(const char *hostname, const U16 port)
configure the udp socket for incoming transmissions
Definition UdpSocket.cpp:69
I32 recvProtocol(const SocketDescriptor &socketDescriptor, U8 *const data, const U32 size) override
Protocol specific implementation of recv. Called directly with error handling from recv.
SocketIpStatus configureSend(const char *hostname, const U16 port, const U32 send_timeout_seconds, const U32 send_timeout_microseconds)
configure the udp socket for outgoing transmissions
Definition UdpSocket.cpp:62
virtual ~UdpSocket()
to cleanup state created at instantiation
Definition UdpSocket.cpp:57
SocketIpStatus
Status enumeration for socket return values.
Definition IpSocket.hpp:29