Raw socket read function.

This commit is contained in:
Bartosz Taudul 2018-09-09 18:24:58 +02:00
parent 806c8de463
commit f55f2858c4
2 changed files with 14 additions and 0 deletions

View File

@ -229,6 +229,19 @@ bool Socket::Read( void* _buf, int len, const timeval* tv, std::function<bool()>
return true;
}
bool Socket::ReadRaw( void* _buf, int len, const timeval* tv )
{
auto buf = (char*)_buf;
while( len > 0 )
{
const auto sz = Recv( buf, len, tv );
if( sz <= 0 ) return false;
len -= sz;
buf += sz;
}
return true;
}
bool Socket::HasData()
{
if( m_bufLeft > 0 ) return true;

View File

@ -27,6 +27,7 @@ public:
int Send( const void* buf, int len );
bool Read( void* buf, int len, const timeval* tv, std::function<bool()> exitCb );
bool ReadRaw( void* buf, int len, const timeval* tv );
bool HasData();
Socket( const Socket& ) = delete;