...
 
Commits (1)
......@@ -508,13 +508,22 @@ DLLEXPORT char* socket_strerror(int error_number, char* buf, size_t buflen)
#endif
}
DLLEXPORT void set_socket_errno(int err)
{
#if defined(_WINSOCKAPI_)
WSASetLastError(err);
#else
errno = err;
#endif
}
DLLEXPORT int xp_inet_pton(int af, const char *src, void *dst)
{
struct addrinfo hints = {0};
struct addrinfo *res, *cur;
if (af != AF_INET && af != AF_INET6) {
// TODO: Should set socket_errno to EAFNOSUPPORT
set_socket_errno(EAFNOSUPPORT);
return -1;
}
......
......@@ -224,6 +224,7 @@ DLLEXPORT uint16_t inet_addrport(union xp_sockaddr *addr);
DLLEXPORT void inet_setaddrport(union xp_sockaddr *addr, uint16_t port);
DLLEXPORT BOOL inet_addrmatch(union xp_sockaddr* addr1, union xp_sockaddr* addr2);
DLLEXPORT char* socket_strerror(int, char*, size_t);
DLLEXPORT void set_socket_errno(int);
DLLEXPORT int xp_inet_pton(int af, const char *src, void *dst);
#if defined(_WIN32) // mingw and WinXP's WS2_32.DLL don't have inet_pton():
#define inet_pton xp_inet_pton
......