diff --git a/common/TracySocket.cpp b/common/TracySocket.cpp index f3d8a8d1..d1b140e6 100755 --- a/common/TracySocket.cpp +++ b/common/TracySocket.cpp @@ -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 ) diff --git a/common/TracySocket.hpp b/common/TracySocket.hpp index e191bae4..9f7c3dd3 100755 --- a/common/TracySocket.hpp +++ b/common/TracySocket.hpp @@ -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;