F´ Flight Software - C/C++ Documentation  devel
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 
24 struct SocketState;
25 
32 class UdpSocket : public IpSocket {
33  public:
37  UdpSocket();
41  virtual ~UdpSocket();
42 
60  SocketIpStatus configureSend(const char* hostname, const U16 port, const U32 send_timeout_seconds,
61  const U32 send_timeout_microseconds);
62 
76  SocketIpStatus configureRecv(const char* hostname, const U16 port);
77 
86  U16 getRecvPort();
87 
88  PROTECTED:
89 
108  I32 sendProtocol(const U8* const data, const U32 size) override;
115  I32 recvProtocol( U8* const data, const U32 size) override;
116  private:
117  SocketState* m_state;
118  U16 m_recv_port;
119  char m_recv_hostname[SOCKET_MAX_HOSTNAME_SIZE];
120 };
121 } // namespace Drv
122 
123 #endif /* DRV_IP_UDPSOCKET_HPP_ */
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
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:47
Helper for setting up Udp using Berkeley sockets as a client.
Definition: UdpSocket.hpp:32
U16 getRecvPort()
get the port being received on
Definition: UdpSocket.cpp:77
SocketIpStatus bind(NATIVE_INT_TYPE fd)
bind the UDP to a port such that it can receive packets at the previously configured port
Definition: UdpSocket.cpp:85
UdpSocket()
Constructor for client socket udp implementation.
Definition: UdpSocket.cpp:53
SocketIpStatus openProtocol(NATIVE_INT_TYPE &fd) override
udp specific implementation for opening a socket.
Definition: UdpSocket.cpp:123
I32 sendProtocol(const U8 *const data, const U32 size) override
Protocol specific implementation of send. Called directly with retry from send.
Definition: UdpSocket.cpp:192
SocketIpStatus configureRecv(const char *hostname, const U16 port)
configure the udp socket for incoming transmissions
Definition: UdpSocket.cpp:68
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
I32 recvProtocol(U8 *const data, const U32 size) override
Protocol specific implementation of recv. Called directly with error handling from recv.
Definition: UdpSocket.cpp:198
virtual ~UdpSocket()
to cleanup state created at instantiation
Definition: UdpSocket.cpp:57
SocketIpStatus
Status enumeration for socket return values.
Definition: IpSocket.hpp:23