LocalPlayer::accelerateHorizontal: cleanups
[oweals/minetest.git] / src / socket.cpp
index 47fffcc4ddbf3a4661733a0e584871e75f1ce288..0bd2702a194b6c6e80a34121dc9092706b9684f1 100644 (file)
@@ -34,9 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "log.h"
 
 #ifdef _WIN32
-       #ifndef WIN32_LEAN_AND_MEAN
-               #define WIN32_LEAN_AND_MEAN
-       #endif
        // Without this some of the network functions are not found on mingw
        #ifndef _WIN32_WINNT
                #define _WIN32_WINNT 0x0501
@@ -44,8 +41,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
        #include <windows.h>
        #include <winsock2.h>
        #include <ws2tcpip.h>
-typedef SOCKET socket_t;
-typedef int socklen_t;
+       #define LAST_SOCKET_ERR() WSAGetLastError()
+       typedef SOCKET socket_t;
+       typedef int socklen_t;
 #else
        #include <sys/types.h>
        #include <sys/socket.h>
@@ -54,7 +52,8 @@ typedef int socklen_t;
        #include <netdb.h>
        #include <unistd.h>
        #include <arpa/inet.h>
-typedef int socket_t;
+       #define LAST_SOCKET_ERR() (errno)
+       typedef int socket_t;
 #endif
 
 // Set to true to enable verbose debug output
@@ -88,9 +87,7 @@ void sockets_cleanup()
 
 Address::Address()
 {
-       m_addr_family = 0;
        memset(&m_address, 0, sizeof(m_address));
-       m_port = 0;
 }
 
 Address::Address(u32 address, u16 port)
@@ -339,7 +336,8 @@ bool UDPSocket::init(bool ipv6, bool noExceptions)
                if (noExceptions) {
                        return false;
                } else {
-                       throw SocketException("Failed to create socket");
+                       throw SocketException(std::string("Failed to create socket: error ")
+                               + itos(LAST_SOCKET_ERR()));
                }
        }