mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Implement checking if there's data to read on the socket.
This commit is contained in:
parent
d999f35dfa
commit
b1fcf88cf4
@ -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 )
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user