mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Socket read loop.
This commit is contained in:
parent
407a256e68
commit
3dd744019a
@ -138,6 +138,21 @@ int Socket::Recv( void* _buf, int len, const timeval* tv )
|
||||
}
|
||||
}
|
||||
|
||||
bool Socket::Read( void* _buf, int len, const timeval* tv, bool(*exitCb)() )
|
||||
{
|
||||
auto buf = (char*)_buf;
|
||||
|
||||
while( len > 0 )
|
||||
{
|
||||
if( exitCb() ) return false;
|
||||
const auto sz = Recv( buf, len, tv );
|
||||
len -= sz;
|
||||
buf += sz;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ListenSocket::ListenSocket()
|
||||
: m_sock( -1 )
|
||||
|
@ -21,6 +21,8 @@ public:
|
||||
int Send( const void* buf, int len );
|
||||
int Recv( void* buf, int len, const timeval* tv );
|
||||
|
||||
bool Read( void* buf, int len, const timeval* tv, bool(*exitCb)() );
|
||||
|
||||
Socket( const Socket& ) = delete;
|
||||
Socket( Socket&& ) = delete;
|
||||
Socket& operator=( const Socket& ) = delete;
|
||||
|
Loading…
Reference in New Issue
Block a user