Skip to content

Commit 81bc27e

Browse files
author
Romain Dura
committed
Use inet_addr if Windows version doesn't support inet_pton
1 parent 64e5c8c commit 81bc27e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Code/NetDebugLog/NetDebugLog.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,16 @@ bool TCPClient::Connect(const char* hostname, unsigned short port)
247247
if (Create())
248248
{
249249
struct sockaddr_in addr;
250+
memset(&addr.sin_zero, 0, sizeof(addr.sin_zero));
250251
addr.sin_family = AF_INET ;
251252
addr.sin_port = htons(port);
252-
memset(&addr.sin_zero, 0, sizeof(addr.sin_zero));
253253

254+
#if (!defined(NTDDI_LONGHORN) || (defined(_WIN32) && NTDDI_VERSION < NTDDI_LONGHORN))
255+
addr.sin_addr.s_addr = inet_addr(hostname);
256+
if (addr.sin_addr.s_addr == INADDR_NONE)
257+
#else
254258
if (inet_pton(AF_INET, hostname, &addr.sin_addr) == 0)
259+
#endif
255260
{
256261
if (EnableErrorLog)
257262
PrintError("TCPClient: Bad address");

0 commit comments

Comments
 (0)