summaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-11-08 18:14:36 -0500
committerkwolekr <kwolekr@minetest.net>2015-11-08 18:16:02 -0500
commit88a3977954f537b391c714be2a52da6b19711154 (patch)
tree69b6b469546b8772a195b80d4886802f919adb1e /src/socket.cpp
parent4ae6e509ffe886492598610a3511179ad87c1f43 (diff)
downloadminetest-88a3977954f537b391c714be2a52da6b19711154.tar.gz
minetest-88a3977954f537b391c714be2a52da6b19711154.tar.bz2
minetest-88a3977954f537b391c714be2a52da6b19711154.zip
Add errno to socket creation failed exception
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 47fffcc4d..17fa1924d 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -44,8 +44,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 +55,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
@@ -339,7 +341,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()));
}
}