]> git.tdb.fi Git - libs/net.git/blob - source/net/inet.h
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / net / inet.h
1 #ifndef MSP_NET_INET_H_
2 #define MSP_NET_INET_H_
3
4 #include "mspnet_api.h"
5 #include "sockaddr.h"
6
7 namespace Msp {
8 namespace Net {
9
10 /**
11 Address class for IPv4 sockets.
12 */
13 class MSPNET_API InetAddr: public SockAddr
14 {
15 private:
16         unsigned char addr[4] = { };
17         unsigned port = 0;
18
19 public:
20         InetAddr() = default;
21         InetAddr(const SysAddr &);
22
23         static InetAddr wildcard(unsigned);
24         static InetAddr localhost(unsigned);
25
26         InetAddr *copy() const override { return new InetAddr(*this); }
27
28         SysAddr to_sys() const override;
29
30         Family get_family() const override { return INET; }
31         unsigned get_port() const { return port; }
32         std::string str() const override;
33 };
34
35 } // namespace Net
36 } // namespace Msp
37
38 #endif