]> git.tdb.fi Git - libs/net.git/blob - source/sockaddr.cpp
Exception changes
[libs/net.git] / source / sockaddr.cpp
1 #include <stdexcept>
2 #include "inet.h"
3 #include "inet6.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace Net {
9
10 SockAddr *SockAddr::create(const sockaddr_storage &sa)
11 {
12         switch(sa.ss_family)
13         {
14         case AF_INET:
15                 return new InetAddr(reinterpret_cast<const sockaddr_in &>(sa));
16         case AF_INET6:
17                 return new Inet6Addr(reinterpret_cast<const sockaddr_in6 &>(sa));
18         default:
19                 throw invalid_argument("SockAddr::create");
20         }
21 }
22
23 unsigned SockAddr::fill_sockaddr(sockaddr_storage &sa) const
24 {
25         return fill_sockaddr(reinterpret_cast<sockaddr &>(sa));
26 }
27
28 } // namespace Net
29 } // namespace Msp