Commit fc6ae220 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Merge branch 'develop' of https://git.rwth-aachen.de/ita/VANet into develop

parents 3bfce9be a68b0e89
......@@ -123,16 +123,19 @@ void CVANetMessage::ReadMessage()
if( nMessageSize > ( int ) m_vecIncomingBuffer.size() )
m_vecIncomingBuffer.resize( nMessageSize );
int iBytesReceivedTotal = 0;
while( nMessageSize > iBytesReceivedTotal )
int iBytesReadTotal = 0;
while( nMessageSize != iBytesReadTotal )
{
int iIncommingBytes = m_pConnection->WaitForIncomingData( 0 );
int iBytesReceived = m_pConnection->ReadRawBuffer( &m_vecIncomingBuffer[ iBytesReceivedTotal ], iIncommingBytes );
iBytesReceivedTotal += iBytesReceived;
int iBytesRead = 0;
if( iBytesReadTotal + iIncommingBytes > nMessageSize )
iBytesRead = m_pConnection->ReadRawBuffer( &m_vecIncomingBuffer[ iBytesReadTotal ], nMessageSize - iBytesReadTotal ); // read residual bytes
else
iBytesRead = m_pConnection->ReadRawBuffer( &m_vecIncomingBuffer[ iBytesReadTotal ], iIncommingBytes ); // read all incominb bytes
iBytesReadTotal += iBytesRead;
}
if( iBytesReceivedTotal != nMessageSize )
VA_EXCEPT2( NETWORK_ERROR, "Reading message, but received less bytes than expected." );
assert( iBytesReadTotal == nMessageSize );
m_oIncoming.SetBuffer( ( VistaType::byte* ) &m_vecIncomingBuffer[ 0 ], nMessageSize, false );
}
......
......@@ -218,8 +218,11 @@ public:
m_mapConnections[ nUpdateID ]->SetWaitForDescriptorEventSelectIsEnabled( true );
}
}
catch( CVAException& )
catch( CVAException& e )
{
#ifdef VANET_SERVER_VERBOSE
std::cerr << "VA Server: caught exception and will disconnect now (" << e << ")" << std::endl;
#endif
m_pParent->RemoveClient( m_mapConnections[ nUpdateID ], CVANetNetworkProtocol::VA_NET_SERVER_DISCONNECT );
}
return false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment