From 0395f9edc71e199caa34b7d1b484aca7791d47db Mon Sep 17 00:00:00 2001 From: Metin Cakircali Date: Tue, 14 Jan 2025 15:38:19 +0100 Subject: [PATCH] fix(TCPSocket): made read/write methods const --- src/eckit/net/TCPSocket.cc | 4 ++-- src/eckit/net/TCPSocket.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/eckit/net/TCPSocket.cc b/src/eckit/net/TCPSocket.cc index 8815fbbd7..7188f137c 100644 --- a/src/eckit/net/TCPSocket.cc +++ b/src/eckit/net/TCPSocket.cc @@ -116,7 +116,7 @@ void TCPSocket::closeInput() { SYSCALL(::shutdown(socket_, SHUT_RD)); } -long TCPSocket::write(const void* buf, long length) { +long TCPSocket::write(const void* buf, long length) const { // Allow zero length packets if (length == 0) { @@ -206,7 +206,7 @@ long TCPSocket::write(const void* buf, long length) { return sent; } -long TCPSocket::read(void* buf, long length) { +long TCPSocket::read(void* buf, long length) const { if (length <= 0) { return length; } diff --git a/src/eckit/net/TCPSocket.h b/src/eckit/net/TCPSocket.h index ec7b996af..bd08a194b 100644 --- a/src/eckit/net/TCPSocket.h +++ b/src/eckit/net/TCPSocket.h @@ -47,7 +47,7 @@ class TCPSocket { TCPSocket& operator=(net::TCPSocket&); - long write(const void* buf, long length); + long write(const void* buf, long length) const; /// Read from a TCP socket /// @@ -59,7 +59,7 @@ class TCPSocket { /// on flaky connections /// \arg **socketSelectTimeout** (*long*): timeout in seconds for the select /// (only if **useSelectOnTCPSocket** is enabled) - long read(void* buf, long length); + long read(void* buf, long length) const; long rawRead(void*, long); // Non-blocking version @@ -121,9 +121,9 @@ class TCPSocket { int sendBufferSize_ = 0; // Debug - bool debug_; - bool newline_; - char mode_; + mutable bool debug_; + mutable bool newline_; + mutable char mode_; protected: // methods int createSocket(int port, const SocketOptions& options);