mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Add errno to socket creation failed exception
This commit is contained in:
parent
4ae6e509ff
commit
88a3977954
@ -44,8 +44,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
typedef SOCKET socket_t;
|
#define LAST_SOCKET_ERR() WSAGetLastError()
|
||||||
typedef int socklen_t;
|
typedef SOCKET socket_t;
|
||||||
|
typedef int socklen_t;
|
||||||
#else
|
#else
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -54,7 +55,8 @@ typedef int socklen_t;
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
typedef int socket_t;
|
#define LAST_SOCKET_ERR() (errno)
|
||||||
|
typedef int socket_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set to true to enable verbose debug output
|
// Set to true to enable verbose debug output
|
||||||
@ -339,7 +341,8 @@ bool UDPSocket::init(bool ipv6, bool noExceptions)
|
|||||||
if (noExceptions) {
|
if (noExceptions) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
throw SocketException("Failed to create socket");
|
throw SocketException(std::string("Failed to create socket: error ")
|
||||||
|
+ itos(LAST_SOCKET_ERR()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ extern bool socket_enable_debug_output;
|
|||||||
class SocketException : public BaseException
|
class SocketException : public BaseException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SocketException(const char *s):
|
SocketException(const std::string &s):
|
||||||
BaseException(s)
|
BaseException(s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
class ResolveError : public BaseException
|
class ResolveError : public BaseException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ResolveError(const char *s):
|
ResolveError(const std::string &s):
|
||||||
BaseException(s)
|
BaseException(s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public:
|
|||||||
class SendFailedException : public BaseException
|
class SendFailedException : public BaseException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SendFailedException(const char *s):
|
SendFailedException(const std::string &s):
|
||||||
BaseException(s)
|
BaseException(s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user