Flair
Framework Libre Air
Socket.h
Go to the documentation of this file.
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 SOCKET_H
14 #define SOCKET_H
15 
16 #include <unistd.h>
17 #include <stdint.h>
18 #include <Object.h>
19 
20 class Socket_impl;
21 
22 namespace flair {
23 namespace core {
24 
31 class Socket : public Object {
32 public:
43  Socket(const Object *parent, std::string name, std::string address,
44  bool broadcast = false);
45 
55  Socket(const Object *parent, std::string name, uint16_t port);
56 
61  ~Socket();
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 Socket_impl *pimpl_;
106 };
107 
108 } // end namespace core
109 } // end namespace flair
110 
111 #endif // SOCKET_H
Socket(const Object *parent, std::string name, std::string address, bool broadcast=false)
Constructor.
Base class for all Framework's classes.
Definition: Object.h:77
namespace of the flair Framework
Definition: Ahrs.h:19
ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout, char *src=NULL, size_t *src_len=NULL)
Receive a message.
unsigned long long Time
Time definition, in ns.
Definition: Object.h:49
Class encapsulating a UDP socket. It assumes packets are coming from only one distant host on a given...
Definition: Socket.h:31
void SendMessage(std::string message)
Send a message.
~Socket()
Destructor.
Base class for all Framework's classes.