Skip to content

Commit

Permalink
Disable TCP stats (not fully implemented)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Jul 12, 2024
1 parent bce07ac commit e248822
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 3 additions & 3 deletions xtransmit/tcp_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ int socket::tcp::write(const const_buffer& buffer, int timeout_ms)
return static_cast<size_t>(res);
}

#ifndef _WIN32
#ifdef ENABLE_TCP_STATS
namespace detail {
const string tcp_info_to_csv(int socketid, const tcp_info& stats, bool print_header)
string tcp_info_to_csv(int socketid, const tcp_info& stats, bool print_header)
{
std::ostringstream output;

Expand Down Expand Up @@ -407,7 +407,7 @@ const string tcp_info_to_csv(int socketid, const tcp_info& stats, bool print_hea

const string socket::tcp::statistics_csv(bool print_header) const
{
#ifndef _WIN32
#ifdef ENABLE_TCP_STATS
tcp_info tcp_stats = {};
socklen_t len = sizeof tcp_stats;

Expand Down
22 changes: 15 additions & 7 deletions xtransmit/tcp_socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class tcp
using string = std::string;

public:
explicit tcp(const UriParser &src_uri);
explicit tcp(const UriParser& src_uri);
tcp(const int sock, bool blocking);
~tcp();

Expand All @@ -44,12 +44,20 @@ class tcp
*
* @throws socket_exception Thrown on failure.
*/
size_t read(const mutable_buffer &buffer, int timeout_ms = -1) final;
int write(const const_buffer &buffer, int timeout_ms = -1) final;
size_t read(const mutable_buffer& buffer, int timeout_ms = -1) final;
int write(const const_buffer& buffer, int timeout_ms = -1) final;

public:
bool supports_statistics() const final { return true; }
const std::string statistics_csv(bool print_header) const final;
bool supports_statistics() const final
{
#ifdef ENABLE_TCP_STATS
return true;
#else
return false;
#endif
}

const std::string statistics_csv(bool print_header) const final;

private:
void raise_exception(const string&& place, const string&& reason) const;
Expand All @@ -62,8 +70,8 @@ class tcp
void set_blocking_flags(bool is_blocking) const;

private:
SOCKET m_bind_socket = -1; // INVALID_SOCK;
sockaddr_in m_dst_addr = {};
SOCKET m_bind_socket = -1; // INVALID_SOCK;
sockaddr_in m_dst_addr = {};

bool m_blocking_mode = false;
string m_host;
Expand Down

0 comments on commit e248822

Please sign in to comment.