summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/ServerHandleImpl.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-07-18 15:20:31 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-07-18 15:20:31 +0200
commit951a0212d8ac12520eaa8236d4b6405d9ddd512c (patch)
treed0e05c36e150a93b9a7775adf9dbcf4ca83004c1 /src/OSSupport/ServerHandleImpl.cpp
parentInitial work on 1.13 entity metadata (#4539) (diff)
downloadcuberite-951a0212d8ac12520eaa8236d4b6405d9ddd512c.tar
cuberite-951a0212d8ac12520eaa8236d4b6405d9ddd512c.tar.gz
cuberite-951a0212d8ac12520eaa8236d4b6405d9ddd512c.tar.bz2
cuberite-951a0212d8ac12520eaa8236d4b6405d9ddd512c.tar.lz
cuberite-951a0212d8ac12520eaa8236d4b6405d9ddd512c.tar.xz
cuberite-951a0212d8ac12520eaa8236d4b6405d9ddd512c.tar.zst
cuberite-951a0212d8ac12520eaa8236d4b6405d9ddd512c.zip
Diffstat (limited to 'src/OSSupport/ServerHandleImpl.cpp')
-rw-r--r--src/OSSupport/ServerHandleImpl.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/OSSupport/ServerHandleImpl.cpp b/src/OSSupport/ServerHandleImpl.cpp
index fb5e16216..1550e38f6 100644
--- a/src/OSSupport/ServerHandleImpl.cpp
+++ b/src/OSSupport/ServerHandleImpl.cpp
@@ -15,13 +15,16 @@
////////////////////////////////////////////////////////////////////////////////
// Globals:
-static bool IsValidSocket(evutil_socket_t a_Socket)
+namespace ServerHandleImplHelper
{
- #ifdef _WIN32
+ static bool IsValidSocket(evutil_socket_t a_Socket)
+ {
+#ifdef _WIN32
return (a_Socket != INVALID_SOCKET);
- #else // _WIN32
+#else // _WIN32
return (a_Socket >= 0);
- #endif // else _WIN32
+#endif // else _WIN32
+ }
}
@@ -129,13 +132,13 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
int err = 0;
evutil_socket_t MainSock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
- if (!IsValidSocket(MainSock))
+ if (!ServerHandleImplHelper::IsValidSocket(MainSock))
{
// Failed to create IPv6 socket, create an IPv4 one instead:
err = EVUTIL_SOCKET_ERROR();
LOGD("Failed to create IPv6 MainSock: %d (%s)", err, evutil_socket_error_to_string(err));
MainSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (!IsValidSocket(MainSock))
+ if (!ServerHandleImplHelper::IsValidSocket(MainSock))
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
Printf(m_ErrorMsg, "Cannot create socket for port %d: %s", a_Port, evutil_socket_error_to_string(m_ErrorCode));
@@ -227,7 +230,7 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
LOGD("Creating a second socket for IPv4");
evutil_socket_t SecondSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (!IsValidSocket(SecondSock))
+ if (!ServerHandleImplHelper::IsValidSocket(SecondSock))
{
err = EVUTIL_SOCKET_ERROR();
LOGD("socket(AF_INET, ...) failed for secondary socket: %d, %s", err, evutil_socket_error_to_string(err));