Skip to content

Commit

Permalink
fix(TCPSocket): made read/write methods const
Browse files Browse the repository at this point in the history
  • Loading branch information
mcakircali committed Jan 14, 2025
1 parent de9e9a2 commit 0395f9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/eckit/net/TCPSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/eckit/net/TCPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0395f9e

Please sign in to comment.