]> git.tdb.fi Git - libs/net.git/blobdiff - source/sockaddr.cpp
Initial revision
[libs/net.git] / source / sockaddr.cpp
diff --git a/source/sockaddr.cpp b/source/sockaddr.cpp
new file mode 100644 (file)
index 0000000..c3ae2db
--- /dev/null
@@ -0,0 +1,26 @@
+/* $Id$
+
+This file is part of libmspnet
+Copyright © 2008  Mikkosoft Productions, Mikko Rasa
+Distributed under the LGPL
+*/
+
+#include <msp/core/except.h>
+#include "inet.h"
+
+namespace Msp {
+namespace Net {
+
+SockAddr *SockAddr::create(sockaddr &sa)
+{
+       switch(sa.sa_family)
+       {
+       case AF_INET:
+               return new InetAddr(reinterpret_cast<sockaddr_in &>(sa));
+       default:
+               throw InvalidParameterValue("Unknown address family");
+       }
+}
+
+} // namespace Net
+} // namespace Msp