From f55f2858c428d9977dad7c9d5bb5247995189d65 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 9 Sep 2018 18:24:58 +0200 Subject: [PATCH] Raw socket read function. --- common/TracySocket.cpp | 13 +++++++++++++ common/TracySocket.hpp | 1 + 2 files changed, 14 insertions(+) diff --git a/common/TracySocket.cpp b/common/TracySocket.cpp index ebbc1f74..4a3e4261 100644 --- a/common/TracySocket.cpp +++ b/common/TracySocket.cpp @@ -229,6 +229,19 @@ bool Socket::Read( void* _buf, int len, const timeval* tv, std::function return true; } +bool Socket::ReadRaw( void* _buf, int len, const timeval* tv ) +{ + auto buf = (char*)_buf; + while( len > 0 ) + { + const auto sz = Recv( buf, len, tv ); + if( sz <= 0 ) return false; + len -= sz; + buf += sz; + } + return true; +} + bool Socket::HasData() { if( m_bufLeft > 0 ) return true; diff --git a/common/TracySocket.hpp b/common/TracySocket.hpp index 9bab6ac0..7a08d797 100644 --- a/common/TracySocket.hpp +++ b/common/TracySocket.hpp @@ -27,6 +27,7 @@ public: int Send( const void* buf, int len ); bool Read( void* buf, int len, const timeval* tv, std::function exitCb ); + bool ReadRaw( void* buf, int len, const timeval* tv ); bool HasData(); Socket( const Socket& ) = delete;