Network: Add support for dual-stack sockets
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// Copyright (C) 2018 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Network module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -827,6 +827,32 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SocketImpl::SetIPv6Only(SocketHandle handle, bool ipv6Only, SocketError* error)
|
||||
{
|
||||
#if NAZARA_CORE_WINDOWS_NT6
|
||||
NazaraAssert(handle != InvalidHandle, "Invalid handle");
|
||||
|
||||
DWORD option = ipv6Only;
|
||||
if (setsockopt(handle, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
||||
{
|
||||
if (error)
|
||||
*error = TranslateWSAErrorToSocketError(WSAGetLastError());
|
||||
|
||||
return false; //< Error
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
|
||||
return true;
|
||||
#else
|
||||
if (error)
|
||||
*error = SocketError_NotSupported;
|
||||
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SocketImpl::SetKeepAlive(SocketHandle handle, bool enabled, UInt64 msTime, UInt64 msInterval, SocketError* error)
|
||||
{
|
||||
NazaraAssert(handle != InvalidHandle, "Invalid handle");
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace Nz
|
||||
|
||||
static bool SetBlocking(SocketHandle handle, bool blocking, SocketError* error = nullptr);
|
||||
static bool SetBroadcasting(SocketHandle handle, bool broadcasting, SocketError* error = nullptr);
|
||||
static bool SetIPv6Only(SocketHandle handle, bool ipv6Only, SocketError* error = nullptr);
|
||||
static bool SetKeepAlive(SocketHandle handle, bool enabled, UInt64 msTime, UInt64 msInterval, SocketError* error = nullptr);
|
||||
static bool SetNoDelay(SocketHandle handle, bool nodelay, SocketError* error = nullptr);
|
||||
static bool SetReceiveBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user