summaryrefslogtreecommitdiffstats
path: root/source/OSSupport/Socket.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-25 16:59:41 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-25 16:59:41 +0200
commit67154217a2be5f66eeaeedd10bcc24d26ce473c2 (patch)
tree4aa33083136074cc45df4d0aa6f33e01eca2e977 /source/OSSupport/Socket.cpp
parentAdded all new bindings, refactored Debuggers; new Debuggers function. (diff)
downloadcuberite-67154217a2be5f66eeaeedd10bcc24d26ce473c2.tar
cuberite-67154217a2be5f66eeaeedd10bcc24d26ce473c2.tar.gz
cuberite-67154217a2be5f66eeaeedd10bcc24d26ce473c2.tar.bz2
cuberite-67154217a2be5f66eeaeedd10bcc24d26ce473c2.tar.lz
cuberite-67154217a2be5f66eeaeedd10bcc24d26ce473c2.tar.xz
cuberite-67154217a2be5f66eeaeedd10bcc24d26ce473c2.tar.zst
cuberite-67154217a2be5f66eeaeedd10bcc24d26ce473c2.zip
Diffstat (limited to '')
-rw-r--r--source/OSSupport/Socket.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/source/OSSupport/Socket.cpp b/source/OSSupport/Socket.cpp
index b4ac62993..48bfc6cfd 100644
--- a/source/OSSupport/Socket.cpp
+++ b/source/OSSupport/Socket.cpp
@@ -294,17 +294,32 @@ cSocket cSocket::AcceptIPv6(void)
if (SClient.IsValid())
{
#if defined(_WIN32)
- // Windows XP doesn't have inet_ntop, so we need to improvise:
- Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x",
- from.sin6_addr.u.Word[0],
- from.sin6_addr.u.Word[1],
- from.sin6_addr.u.Word[2],
- from.sin6_addr.u.Word[3],
- from.sin6_addr.u.Word[4],
- from.sin6_addr.u.Word[5],
- from.sin6_addr.u.Word[6],
- from.sin6_addr.u.Word[7]
- );
+ // Windows XP doesn't have inet_ntop, so we need to improvise. And MSVC has different headers than GCC
+ #ifdef _MSC_VER
+ // MSVC version
+ Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x",
+ from.sin6_addr.u.Word[0],
+ from.sin6_addr.u.Word[1],
+ from.sin6_addr.u.Word[2],
+ from.sin6_addr.u.Word[3],
+ from.sin6_addr.u.Word[4],
+ from.sin6_addr.u.Word[5],
+ from.sin6_addr.u.Word[6],
+ from.sin6_addr.u.Word[7]
+ );
+ #else // _MSC_VER
+ // MinGW
+ Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x",
+ from.sin6_addr.s6_addr16[0],
+ from.sin6_addr.s6_addr16[1],
+ from.sin6_addr.s6_addr16[2],
+ from.sin6_addr.s6_addr16[3],
+ from.sin6_addr.s6_addr16[4],
+ from.sin6_addr.s6_addr16[5],
+ from.sin6_addr.s6_addr16[6],
+ from.sin6_addr.s6_addr16[7]
+ );
+ #endif // else _MSC_VER
#else
char buffer[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &(from.sin6_addr), buffer, sizeof(buffer));