Flair
Framework Libre Air
UdtSocket.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 UDTSOCKET_H
14 #define UDTSOCKET_H
15 
16 typedef int UDTSOCKET;
17 
18 #include <ConnectedSocket.h>
19 
20 namespace flair {
21 namespace core {
27 class UdtSocket : public ConnectedSocket {
28 public:
29  UdtSocket(const Object *parent, const std::string name,
30  bool blockOnSend = false, bool blockOnReceive = true);
31  ~UdtSocket();
32  void Listen(const unsigned int port, const std::string localAddress = "ANY");
33  UdtSocket *
34  Accept(Time timeout); // should throw an exception if not a listening socket
35  bool Connect(const unsigned int port, const std::string distantAddress,
36  Time timeout); // /!\ timeout is ignored
37  ssize_t SendMessage(const char *message, size_t message_len, Time timeout);
38  ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout);
39 
40  uint16_t NetworkToHost16(uint16_t data);
41  uint16_t HostToNetwork16(uint16_t data);
42  uint32_t NetworkToHost32(uint32_t data);
43  uint32_t HostToNetwork32(uint32_t data);
44 
45 private:
46  UDTSOCKET socket;
47  bool blockOnSend;
48  bool blockOnReceive;
49 };
50 
51 } // end namespace core
52 } // end namespace flair
53 
54 #endif // UDTSOCKET_H
Interface class encapsulating a connected socket. Preserves packets order and guaranty delivery...
Definition: ConnectedSocket.h:27
void Listen(const unsigned int port, const std::string localAddress="ANY")
Returns a socket which listens on a specific port/address.
Base class for all Framework's classes.
Definition: Object.h:83
namespace of the flair Framework
Definition: Ahrs.h:19
ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout)
Receive a message.
unsigned long long Time
Time definition, in ns.
Definition: Object.h:55
bool Connect(const unsigned int port, const std::string distantAddress, Time timeout)
Returns a socket connected to a distant host.
Class defining a socket working in connected mode.
Class encapsulating a UDT socket.
Definition: UdtSocket.h:27
uint16_t NetworkToHost16(uint16_t data)
! See Socket.h for a more generic implementation of network/host endianness
UdtSocket * Accept(Time timeout)
Returns a socket on a new incoming connexion.
ssize_t SendMessage(const char *message, size_t message_len, Time timeout)
Send a message waiting up to timeout ns.