5 #ifndef __MESSAGEUDP_H__ 6 #define __MESSAGEUDP_H__ 26 virtual bool recvFrom(Messagegram *)
override;
27 virtual bool recvFrom(Messagegram *,
long seconds,
long uSeconds)
override;
28 virtual bool recvLargeFrom(Messagegram *)
override;
29 virtual void getRecvAddress(uint32_t &address)
override;
30 virtual void convertAddressToStr(
const uint32_t address,
31 char *addStr)
override;
32 virtual bool replyLast(
const Messagegram &)
override;
33 virtual bool sendTo(
const Messagegram &,
const char *, uint16_t)
override;
34 virtual bool sendLargeTo(
const Messagegram &,
35 const char *, uint16_t)
override;
36 virtual bool bind(
const char *, uint16_t)
override;
37 virtual bool bind(uint16_t)
override;
38 virtual uint16_t bindRandom()
override;
39 virtual bool postInit()
override;
40 virtual bool setReceiveBufferSize(
int bufferSize)
override;
41 virtual bool setSendBufferSize(
int bufferSize)
override;
42 virtual bool setBroadcast(
bool boardcast)
override;
43 virtual bool setReusePort(
bool reuse)
override;
44 virtual bool setReuseAddress(
bool reuse)
override;
45 virtual void shutdown()
override;
48 bool receiveFrom(
char *mesg, uint16_t *bytesRecv,
49 uint16_t maxLen, sockaddr_in *recvFrom,
50 long seconds,
long uSeconds,
int flags = 0);
51 bool receiveFrom(
char *mesg, uint16_t *bytesRecv, uint16_t maxLen,
52 sockaddr_in *recvFrom,
int flags = 0);
53 bool receiveLargeFrom(
char *mesg, uint16_t *bytesRecv, uint16_t maxLen,
54 sockaddr_in *recvFrom,
int flags = 0);
55 bool sendTo(sockaddr_in &addr,
const char *mesg, uint16_t mesgLen,
57 bool bindTo(
const char *host, uint16_t port);
58 bool bindTo(uint16_t port);
64 MessageAddress() : m_isValid(
false) {}
66 MessageAddress(
const char *host,
unsigned short port)
67 : m_host(host), m_port(port)
69 int addrLen =
sizeof(m_addr);
70 memset(&m_addr, 0, addrLen);
71 m_addr.sin_family = AF_INET;
72 m_addr.sin_port = htons(m_port);
73 inet_pton(AF_INET, m_host.c_str(), &m_addr.sin_addr);
77 MessageAddress(
struct sockaddr_in addr) : m_addr(addr)
81 inet_ntop(AF_INET, &m_addr.sin_addr, ip, 256);
82 m_port = ntohs(m_addr.sin_port);
87 MessageAddress &operator=(
const MessageAddress &other)
89 m_host = other.m_host;
90 m_port = other.m_port;
91 m_addr = other.m_addr;
92 m_isValid = other.m_isValid;
96 const std::string& getHost()
const {
return m_host; }
97 unsigned short getPort()
const {
return m_port; }
98 struct sockaddr_in getNetAddress() const {
return m_addr; }
99 bool isValid()
const {
return m_isValid; }
104 unsigned short m_port;
105 struct sockaddr_in m_addr;
109 MessageAddress m_replyAddr;
115 #endif // __MESSAGEUDP_H__ Message Sender/Receiver.
Definition: MessageI.h:35
kernel
Definition: namespace.dox:3
Message Sender/Receiver over UDP.
Definition: MessageUDP.h:20