Commit e574155e authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Don't use inet_ntop() on Windows as XP didn't include it

As reported by cadeon on Vertrauen, Synchronet v3.19 hasn't worked on Windows XP due to error:
'The procedure entry point inet_ntop could not be located in the dynamic link library WS2_32.dll'
parent 4c19e4fb
......@@ -5731,9 +5731,8 @@ NO_SSH:
result = connect(new_node->passthru_socket, (struct sockaddr *)&tmp_addr, tmp_addr_len);
if(result != 0) {
inet_ntop(tmp_addr.sin_family, &tmp_addr.sin_addr, addr_str, sizeof(addr_str));
lprintf(LOG_ERR,"Node %d !ERROR %d (%d) connecting to passthru socket: %s port %u"
,new_node->cfg.node_num, result, ERROR_VALUE, addr_str, htons(tmp_addr.sin_port));
,new_node->cfg.node_num, result, ERROR_VALUE, inet_ntoa(tmp_addr.sin_addr), htons(tmp_addr.sin_port));
......@@ -151,19 +151,25 @@ struct in6_addr parseIPv6Address(const char* value)
const char* IPv4AddressToStr(uint32_t addr, char* dest, size_t size)
const char* result;
struct in_addr in_addr;
in_addr.s_addr = htonl(addr);
#if defined(__BORLANDC__) || defined(__MINGW32__)
result = inet_ntoa(in_addr); // deprecated function call
if(result == NULL)
#if defined _WIN32
int result;
WSADATA wsaData;
SOCKADDR_IN sockaddr = {0};
sockaddr.sin_family = AF_INET;
sockaddr.sin_addr.s_addr = htonl(addr);
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
return NULL;
strncpy(dest, result, size);
result = dest;
result = getnameinfo((SOCKADDR*)&sockaddr, sizeof(sockaddr), dest, size, NULL, 0, NI_NUMERICHOST);
if(result != 0)
return NULL;
return dest;
result = inet_ntop(AF_INET, &in_addr, dest, size);
struct in_addr in_addr;
in_addr.s_addr = htonl(addr);
return inet_ntop(AF_INET, &in_addr, dest, size);
return result;
......@@ -180,6 +186,7 @@ int main(int argc, char** argv)
printf("%s\n", getHostNameByAddr(argv[1]));
return 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment