Skip to content
Snippets Groups Projects
Commit 33d57538 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Introduce and use set_socket_errno()

xp_inet_pton() now sets the socket errno value, doing as instructed by the TODO.
parent bc007231
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #943 passed
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment