mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Engine: improve CNetConBase::Recv
- ::recv with MSG_PEEK still needs to know the full buffer length. - Improve disconnect reason.
This commit is contained in:
parent
def96b25a7
commit
5d7c94ae2f
@ -298,14 +298,14 @@ void CNetConBase::Recv(CConnectedNetConsoleData& data, const int nMaxLen)
|
||||
static char szRecvBuf[1024];
|
||||
|
||||
{//////////////////////////////////////////////
|
||||
const int nPendingLen = ::recv(data.m_hSocket, szRecvBuf, sizeof(char), MSG_PEEK);
|
||||
const int nPendingLen = ::recv(data.m_hSocket, szRecvBuf, sizeof(szRecvBuf), MSG_PEEK);
|
||||
if (nPendingLen == SOCKET_ERROR && m_Socket.IsSocketBlocking())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (nPendingLen == 0) // Socket was closed.
|
||||
{
|
||||
Disconnect("remote closed socket");
|
||||
Disconnect("socket closed prematurely");
|
||||
return;
|
||||
}
|
||||
else if (nPendingLen < 0)
|
||||
@ -315,8 +315,8 @@ void CNetConBase::Recv(CConnectedNetConsoleData& data, const int nMaxLen)
|
||||
}
|
||||
}//////////////////////////////////////////////
|
||||
|
||||
int nReadLen = 0; // Find out how much we have to read.
|
||||
int iResult = ::ioctlsocket(data.m_hSocket, FIONREAD, reinterpret_cast<u_long*>(&nReadLen));
|
||||
u_long nReadLen = 0; // Find out how much we have to read.
|
||||
const int iResult = ::ioctlsocket(data.m_hSocket, FIONREAD, &nReadLen);
|
||||
|
||||
if (iResult == SOCKET_ERROR)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user