Network/TcpClient: Fix LowDelay

Former-commit-id: 70fc4224ae7f8913e27a3a3cf234500db262f73c
This commit is contained in:
Lynix
2015-11-12 13:19:21 +01:00
parent a26c979d84
commit 81221fbf0b
3 changed files with 22 additions and 2 deletions

View File

@@ -534,6 +534,25 @@ namespace Nz
return true;
}
bool SocketImpl::SetNoDelay(SocketHandle handle, bool nodelay, SocketError* error)
{
NazaraAssert(handle != InvalidHandle, "Invalid handle");
BOOL option = nodelay;
if (setsockopt(handle, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
{
if (error)
*error = TranslateWSAErrorToSocketError(WSAGetLastError());
return false; //< Error
}
if (error)
*error = SocketError_NoError;
return true;
}
SocketError SocketImpl::TranslateWSAErrorToSocketError(int error)
{
switch (error)

View File

@@ -48,6 +48,7 @@ namespace Nz
static bool SetBlocking(SocketHandle handle, bool blocking, 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 SocketError TranslateWSAErrorToSocketError(int error);
static int TranslateNetProtocolToAF(NetProtocol protocol);