]> git.tdb.fi Git - libs/net.git/blob - source/net/sockaddr.cpp
Include the matching header first in .cpp files
[libs/net.git] / source / net / sockaddr.cpp
1 #include "sockaddr.h"
2 #include <stdexcept>
3 #include "platform_api.h"
4 #include "inet.h"
5 #include "inet6.h"
6 #include "sockaddr_private.h"
7 #include "unix.h"
8
9 using namespace std;
10
11 namespace Msp {
12 namespace Net {
13
14 SockAddr *SockAddr::new_from_sys(const SysAddr &sa)
15 {
16         switch(sa.addr.ss_family)
17         {
18         case AF_INET:
19                 return new InetAddr(sa);
20         case AF_INET6:
21                 return new Inet6Addr(sa);
22         case AF_UNIX:
23                 return new UnixAddr(sa);
24         default:
25                 throw invalid_argument("SockAddr::create");
26         }
27 }
28
29 SockAddr::SysAddr::SysAddr()
30 {
31         addr.ss_family = AF_UNSPEC;
32 }
33
34 } // namespace Net
35 } // namespace Msp