]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/datagramsocket.cpp
Use the correct #ifdef for Windows
[libs/net.git] / source / net / datagramsocket.cpp
index d24ca4e1ec8ec1c10fcd11c3188da874426b053b..0e405d6f0cb7972fed62e418d447a2dc4c303b31 100644 (file)
@@ -1,3 +1,6 @@
+#ifdef _WIN32
+#include <winsock2.h>
+#endif
 #include <cerrno>
 #include <msp/core/systemerror.h>
 #include <msp/io/handle_private.h>
@@ -12,7 +15,7 @@ namespace Net {
 DatagramSocket::DatagramSocket(Family f, int p):
        ClientSocket(f, SOCK_DGRAM, p)
 {
-#ifdef WIN32
+#ifdef _WIN32
        WSAEventSelect(priv->handle, *priv->event, FD_READ|FD_CLOSE);
 #endif
        set_events(IO::P_INPUT);
@@ -25,7 +28,7 @@ bool DatagramSocket::connect(const SockAddr &addr)
        int err = ::connect(priv->handle, reinterpret_cast<sockaddr *>(&sa.addr), sa.size);
        if(err==-1)
        {
-#ifdef WIN32
+#ifdef _WIN32
                throw system_error("connect", WSAGetLastError());
 #else
                throw system_error("connect");
@@ -59,7 +62,7 @@ unsigned DatagramSocket::sendto(const char *buf, unsigned size, const SockAddr &
                        return 0;
                else
                {
-#ifdef WIN32
+#ifdef _WIN32
                        throw system_error("sendto", WSAGetLastError());
 #else
                        throw system_error("sendto");
@@ -83,7 +86,7 @@ unsigned DatagramSocket::recvfrom(char *buf, unsigned size, SockAddr *&from_addr
                        return 0;
                else
                {
-#ifdef WIN32
+#ifdef _WIN32
                        throw system_error("recvfrom", WSAGetLastError());
 #else
                        throw system_error("recvfrom");