Free Electron
MessageI.h
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 #ifndef __MESSAGEI_H__
6 #define __MESSAGEI_H__
7 
8 #pragma pack(push, 1)
9 
10 #define MESSAGEGRAM_MAXDATA 1400
11 #define MESSAGE_UDP_MAXDATA 65507
12 #define MAX_RANDOM_BIND_TRIES 1024
13 
14 namespace fe
15 {
16 namespace ext
17 {
18 
19 //~typedef unsigned int uint32;
20 //~typedef unsigned short uint16;
21 //~typedef unsigned char uint8;
22 
23 // message payload
24 struct Messagegram
25 {
26  uint16_t dataLen;
27  uint8_t data[MESSAGE_UDP_MAXDATA];
28 };
29 
30 /**************************************************************************//**
31  @brief Message Sender/Receiver
32 
33  @ingroup message
34 *//***************************************************************************/
35 class FE_DL_EXPORT MessageI : virtual public fe::Component, public fe::CastableAs<MessageI>
36 {
37 public:
38  virtual bool recvFrom(Messagegram *) = 0;
39  virtual bool recvFrom(Messagegram *, long seconds, long uSeconds) = 0;
40  virtual bool recvLargeFrom(Messagegram *) = 0;
41  virtual void getRecvAddress(uint32_t &address) = 0;
42  virtual void convertAddressToStr(const uint32_t address, char *addStr) = 0;
43  virtual bool replyLast(const Messagegram &) = 0;
44  virtual bool sendLargeTo(const Messagegram &, const char *, uint16_t) = 0;
45  virtual bool sendTo(const Messagegram &, const char *, uint16_t) = 0;
46  virtual bool bind(const char *, uint16_t) = 0;
47  virtual bool bind(uint16_t) = 0;
48  virtual uint16_t bindRandom() = 0;
49  virtual bool postInit() = 0;
50  virtual bool setReceiveBufferSize(int bufferSize) = 0;
51  virtual bool setSendBufferSize(int bufferSize) = 0;
52  virtual bool setBroadcast(bool boardcast) = 0;
53  virtual bool setReusePort(bool reuse) = 0;
54  virtual bool setReuseAddress(bool reuse) = 0;
55  virtual void shutdown() = 0;
56 };
57 
58 } // namespace ext
59 } // namespace fe
60 
61 #pragma pack(pop)
62 
63 #endif // __MESSAGEI_H__
Message Sender/Receiver.
Definition: MessageI.h:35
kernel
Definition: namespace.dox:3
Base for all interfacable components.
Definition: Component.h:20
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192