mirror of
https://github.com/wolfpld/tracy.git
synced 2024-12-01 17:34:36 +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;
|
return buf - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Socket::Recv( void* _buf, int len )
|
int Socket::Recv( void* _buf, int len, const timeval* tv )
|
||||||
{
|
{
|
||||||
auto buf = (char*)_buf;
|
auto buf = (char*)_buf;
|
||||||
assert( m_sock != -1 );
|
|
||||||
int size;
|
fd_set fds;
|
||||||
do
|
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>
|
#include <memory>
|
||||||
|
|
||||||
|
struct timeval;
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ public:
|
|||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
int Send( const void* buf, int len );
|
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( const Socket& ) = delete;
|
||||||
Socket( Socket&& ) = delete;
|
Socket( Socket&& ) = delete;
|
||||||
|
Loading…
Reference in New Issue
Block a user