mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +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;
|
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()
|
ListenSocket::ListenSocket()
|
||||||
: m_sock( -1 )
|
: m_sock( -1 )
|
||||||
|
@ -22,6 +22,7 @@ public:
|
|||||||
int Recv( void* buf, int len, const timeval* tv );
|
int Recv( void* buf, int len, const timeval* tv );
|
||||||
|
|
||||||
bool Read( void* buf, int len, const timeval* tv, bool(*exitCb)() );
|
bool Read( void* buf, int len, const timeval* tv, bool(*exitCb)() );
|
||||||
|
bool HasData();
|
||||||
|
|
||||||
Socket( const Socket& ) = delete;
|
Socket( const Socket& ) = delete;
|
||||||
Socket( Socket&& ) = delete;
|
Socket( Socket&& ) = delete;
|
||||||
|
Loading…
Reference in New Issue
Block a user