]> git.tdb.fi Git - libs/net.git/blobdiff - source/resolve.cpp
Hide AF_* constants from the public header
[libs/net.git] / source / resolve.cpp
index e732fc040dfe037334cd203dc19fb2fc88f93906..3896db7a81a5d1c0a3be8ccef6667947e4b814f5 100644 (file)
@@ -4,7 +4,8 @@
 #else
 #include <netdb.h>
 #endif
-#include <msp/strings/formatter.h>
+#include <msp/core/systemerror.h>
+#include <msp/strings/format.h>
 #include "socket.h"
 #include "resolve.h"
 
@@ -36,7 +37,7 @@ SockAddr *resolve(const string &s, Family family)
                        host = s;
        }
 
-       addrinfo hints = {0, family, 0, 0, 0, 0, 0, 0};
+       addrinfo hints = { 0, family_to_sys(family), 0, 0, 0, 0, 0, 0 };
        addrinfo *res;
        const char *chost = (host.empty() ? 0 : host.c_str());
        const char *cserv = (serv.empty() ? 0 : serv.c_str());
@@ -49,9 +50,9 @@ SockAddr *resolve(const string &s, Family family)
        }
        else
 #ifdef WIN32
-               throw Exception(format("Can't resolve '%s': %d", host, err));
+               throw system_error("getaddrinfo", WSAGetLastError());
 #else
-               throw Exception(format("Can't resolve '%s': %s", host, gai_strerror(err)));
+               throw system_error("getaddrinfo", gai_strerror(err));
 #endif
 }