F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
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 
19 namespace Drv {
20 
21 struct SocketState;
22 
29 class UdpSocket : public IpSocket {
30  public:
34  UdpSocket();
38  virtual ~UdpSocket();
39 
45  SocketIpStatus configure(const char* hostname, const U16 port, const U32 send_timeout_seconds,
46  const U32 send_timeout_microseconds) override;
47 
65  SocketIpStatus configureSend(const char* hostname, const U16 port, const U32 send_timeout_seconds,
66  const U32 send_timeout_microseconds);
67 
81  SocketIpStatus configureRecv(const char* hostname, const U16 port);
82 
91  U16 getRecvPort();
92 
93  PROTECTED:
94 
106  SocketIpStatus openProtocol(SocketDescriptor& socketDescriptor) override;
114  I32 sendProtocol(const SocketDescriptor& socketDescriptor, const U8* const data, const U32 size) override;
122  I32 recvProtocol(const SocketDescriptor& socketDescriptor, U8* const data, const U32 size) override;
123  private:
124  SocketState* m_state;
125  U16 m_recv_port;
126  char m_recv_hostname[SOCKET_MAX_HOSTNAME_SIZE];
127 };
128 } // namespace Drv
129 
130 #endif /* DRV_IP_UDPSOCKET_HPP_ */
U16 getRecvPort()
get the port being received on
Definition: UdpSocket.cpp:83
SocketIpStatus configureRecv(const char *hostname, const U16 port)
configure the udp socket for incoming transmissions
Definition: UdpSocket.cpp:75
virtual ~UdpSocket()
to cleanup state created at instantiation
Definition: UdpSocket.cpp:57
Helper for setting up Udp using Berkeley sockets as a client.
Definition: UdpSocket.hpp:29
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:89
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
I32 sendProtocol(const SocketDescriptor &socketDescriptor, const U8 *const data, const U32 size) override
Protocol specific implementation of send. Called directly with retry from send.
Definition: UdpSocket.cpp:194
I32 recvProtocol(const SocketDescriptor &socketDescriptor, U8 *const data, const U32 size) override
Protocol specific implementation of recv. Called directly with error handling from recv...
Definition: UdpSocket.cpp:200
UdpSocket()
Constructor for client socket udp implementation.
Definition: UdpSocket.cpp:53
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:68
C++-compatible configuration header for fprime configuration.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
SocketIpStatus
Status enumeration for socket return values.
Definition: IpSocket.hpp:29
Helper base-class for setting up Berkeley sockets.
Definition: IpSocket.hpp:57
SocketIpStatus configure(const char *hostname, const U16 port, const U32 send_timeout_seconds, const U32 send_timeout_microseconds) override
configure is disabled
Definition: UdpSocket.cpp:62
SocketIpStatus openProtocol(SocketDescriptor &socketDescriptor) override
udp specific implementation for opening a socket.
Definition: UdpSocket.cpp:121