Network/AbstractSocket: Prevent querying/setting receive/send buffer size without opening the socket first

This commit is contained in:
Jérôme Leclercq 2017-01-23 11:58:05 +01:00
parent f8357526b9
commit 071147bf51
2 changed files with 9 additions and 9 deletions

View File

@ -1,4 +1,4 @@
// Copyright (C) 2017 Jérôme Leclercq
// Copyright (C) 2017 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

View File

@ -117,8 +117,7 @@ namespace Nz
*/
std::size_t AbstractSocket::QueryReceiveBufferSize() const
{
if (m_handle == SocketImpl::InvalidHandle)
return 0;
NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket must be created first");
return SocketImpl::QueryReceiveBufferSize(m_handle);
}
@ -129,8 +128,7 @@ namespace Nz
*/
std::size_t AbstractSocket::QuerySendBufferSize() const
{
if (m_handle == SocketImpl::InvalidHandle)
return 0;
NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket must be created first");
return SocketImpl::QuerySendBufferSize(m_handle);
}
@ -142,8 +140,9 @@ namespace Nz
*/
void AbstractSocket::SetReceiveBufferSize(std::size_t size)
{
if (m_handle != SocketImpl::InvalidHandle)
SocketImpl::SetReceiveBufferSize(m_handle, size);
NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket must be created first");
SocketImpl::SetReceiveBufferSize(m_handle, size);
}
/*!
@ -153,8 +152,9 @@ namespace Nz
*/
void AbstractSocket::SetSendBufferSize(std::size_t size)
{
if (m_handle != SocketImpl::InvalidHandle)
SocketImpl::SetSendBufferSize(m_handle, size);
NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket must be created first");
SocketImpl::SetSendBufferSize(m_handle, size);
}
/*!