Flair
Framework Libre Air
UdpSocket.h
1 // %flair:license{
2 // This file is part of the Flair framework distributed under the
3 // CECILL-C License, Version 1.0.
4 // %flair:license}
13 #ifndef UDPSOCKET_H
14 #define UDPSOCKET_H
15 
16 #include <unistd.h>
17 #include <stdint.h>
18 #include <Object.h>
19 
20 class UdpSocket_impl;
21 
22 namespace flair {
23 namespace core {
24 
31 class UdpSocket : public Object {
32 public:
43  UdpSocket(const Object *parent, std::string name, std::string address,
44  bool broadcast = false);
45 
55  UdpSocket(const Object *parent, std::string name, uint16_t port);
56 
61  ~UdpSocket();
62 
71  void SendMessage(std::string message);
72 
79  void SendMessage(const char *message, size_t message_len);
80 
98  ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout, char *src = NULL,
99  size_t *src_len = NULL);
100 
101  void NetworkToHost(char *data, size_t dataSize);
102  void HostToNetwork(char *data, size_t dataSize);
103 
104 private:
105  class UdpSocket_impl *pimpl_;
106 };
107 
108 } // end namespace core
109 } // end namespace flair
110 
111 #endif // UDPSOCKET_H
Base class for all Framework's classes.
Definition: Object.h:83
namespace of the flair Framework
Definition: Ahrs.h:19
unsigned long long Time
Time definition, in ns.
Definition: Object.h:55
ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout, char *src=NULL, size_t *src_len=NULL)
Receive a message.
~UdpSocket()
Destructor.
Base class for all Framework's classes.
void SendMessage(std::string message)
Send a message.
UdpSocket(const Object *parent, std::string name, std::string address, bool broadcast=false)
Constructor.
Class encapsulating a UDP socket. It assumes packets are coming from only one distant host on a given...
Definition: UdpSocket.h:31