diff --git a/common/TracySocket.cpp b/common/TracySocket.cpp index 5a15b3e1..b3efb09f 100755 --- a/common/TracySocket.cpp +++ b/common/TracySocket.cpp @@ -162,6 +162,19 @@ bool Socket::Read( void* _buf, int len, const timeval* tv, bool(*exitCb)() ) return true; } +bool Socket::HasData() +{ + struct timeval tv; + memset( &tv, 0, sizeof( tv ) ); + + fd_set fds; + FD_ZERO( &fds ); + FD_SET( m_sock, &fds ); + + select( m_sock+1, &fds, nullptr, nullptr, &tv ); + return FD_ISSET( m_sock, &fds ); +} + ListenSocket::ListenSocket() : m_sock( -1 ) diff --git a/common/TracySocket.hpp b/common/TracySocket.hpp index 9f7c3dd3..e1070cf1 100755 --- a/common/TracySocket.hpp +++ b/common/TracySocket.hpp @@ -22,6 +22,7 @@ public: int Recv( void* buf, int len, const timeval* tv ); bool Read( void* buf, int len, const timeval* tv, bool(*exitCb)() ); + bool HasData(); Socket( const Socket& ) = delete; Socket( Socket&& ) = delete;