mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Use select in Recv().
This commit is contained in:
parent
953e9c6206
commit
365f2cde23
@ -119,17 +119,23 @@ int Socket::Send( const void* _buf, int len )
|
||||
return buf - start;
|
||||
}
|
||||
|
||||
int Socket::Recv( void* _buf, int len )
|
||||
int Socket::Recv( void* _buf, int len, const timeval* tv )
|
||||
{
|
||||
auto buf = (char*)_buf;
|
||||
assert( m_sock != -1 );
|
||||
int size;
|
||||
do
|
||||
|
||||
fd_set fds;
|
||||
FD_ZERO( &fds );
|
||||
FD_SET( m_sock, &fds );
|
||||
|
||||
select( m_sock+1, &fds, nullptr, nullptr, tv );
|
||||
if( FD_ISSET( m_sock, &fds ) )
|
||||
{
|
||||
size = recv( m_sock, buf, len, 0 );
|
||||
return recv( m_sock, buf, len, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
while( size == -1 );
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
struct timeval;
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
@ -17,7 +19,7 @@ public:
|
||||
void Close();
|
||||
|
||||
int Send( const void* buf, int len );
|
||||
int Recv( void* buf, int len );
|
||||
int Recv( void* buf, int len, const timeval* tv );
|
||||
|
||||
Socket( const Socket& ) = delete;
|
||||
Socket( Socket&& ) = delete;
|
||||
|
Loading…
Reference in New Issue
Block a user