]> git.tdb.fi Git - libs/net.git/blob - source/net/sockaddr.h
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / net / sockaddr.h
1 #ifndef MSP_NET_SOCKADDR_H_
2 #define MSP_NET_SOCKADDR_H_
3
4 #include <string>
5 #include "mspnet_api.h"
6
7 namespace Msp {
8 namespace Net {
9
10 enum Family
11 {
12         UNSPEC,
13         INET,
14         INET6,
15         UNIX
16 };
17
18
19 class MSPNET_API SockAddr
20 {
21 public:
22         struct SysAddr;
23
24 protected:
25         SockAddr() = default;
26         SockAddr(const SockAddr &) = default;
27         SockAddr(SockAddr &&) = default;
28         SockAddr &operator=(const SockAddr &) = default;
29         SockAddr &operator=(SockAddr &&) = default;
30 public:
31         virtual ~SockAddr() = default;
32
33         virtual SockAddr *copy() const = 0;
34
35         static SockAddr *new_from_sys(const SysAddr &);
36         virtual SysAddr to_sys() const = 0;
37
38         virtual Family get_family() const = 0;
39         virtual std::string str() const = 0;
40 };
41
42 } // namespace Net
43 } // namespace Msp
44
45 #endif