summaryrefslogtreecommitdiffstats
path: root/source/OSSupport/Socket.cpp
diff options
context:
space:
mode:
authormadmaxoft <madmaxoft@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-05 14:35:19 +0100
committermadmaxoft <madmaxoft@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-05 14:35:19 +0100
commitfcdc68fd8e777fa4c852acf7e471de914e4d7ee7 (patch)
treebf1dc6ab80930c8bee3d08375539517fc6a2845b /source/OSSupport/Socket.cpp
parentFixed logic in socketthreads connecting (diff)
downloadcuberite-fcdc68fd8e777fa4c852acf7e471de914e4d7ee7.tar
cuberite-fcdc68fd8e777fa4c852acf7e471de914e4d7ee7.tar.gz
cuberite-fcdc68fd8e777fa4c852acf7e471de914e4d7ee7.tar.bz2
cuberite-fcdc68fd8e777fa4c852acf7e471de914e4d7ee7.tar.lz
cuberite-fcdc68fd8e777fa4c852acf7e471de914e4d7ee7.tar.xz
cuberite-fcdc68fd8e777fa4c852acf7e471de914e4d7ee7.tar.zst
cuberite-fcdc68fd8e777fa4c852acf7e471de914e4d7ee7.zip
Diffstat (limited to '')
-rw-r--r--source/OSSupport/Socket.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/source/OSSupport/Socket.cpp b/source/OSSupport/Socket.cpp
index 2412852d5..efc20284f 100644
--- a/source/OSSupport/Socket.cpp
+++ b/source/OSSupport/Socket.cpp
@@ -265,37 +265,40 @@ bool cSocket::Listen(int a_Backlog)
-cSocket cSocket::Accept()
+cSocket cSocket::AcceptIPv4(void)
{
sockaddr_in from;
- socklen_t fromlen=sizeof(from);
+ socklen_t fromlen = sizeof(from);
- cSocket SClient = accept(m_Socket, (sockaddr*)&from, &fromlen);
+ cSocket SClient = accept(m_Socket, (sockaddr *)&from, &fromlen);
if (SClient.IsValid() && (from.sin_addr.s_addr != 0)) // Get IP in string form
{
SClient.m_IPString = inet_ntoa(from.sin_addr);
}
-
return SClient;
}
-
-/*
-int cSocket::Connect(SockAddr_In & a_Address)
+
+cSocket cSocket::AcceptIPv6(void)
{
- sockaddr_in local;
+ sockaddr_in6 from;
+ socklen_t fromlen = sizeof(from);
- local.sin_family = a_Address.Family;
- local.sin_addr.s_addr = a_Address.Address;
- local.sin_port = htons((u_short)a_Address.Port);
+ cSocket SClient = accept(m_Socket, (sockaddr *)&from, &fromlen);
- return connect(m_Socket, (sockaddr *)&local, sizeof(local));
+ // Get IP in string form:
+ if (SClient.IsValid())
+ {
+ char buffer[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &(from.sin6_addr), buffer, sizeof(buffer));
+ SClient.m_IPString.assign(buffer);
+ }
+ return SClient;
}
-*/