@@ -64,7 +64,7 @@ class Sock
6464 * Get the value of the contained socket.
6565 * @return socket or INVALID_SOCKET if empty
6666 */
67- virtual SOCKET Get () const ;
67+ [[nodiscard]] virtual SOCKET Get () const ;
6868
6969 /* *
7070 * Get the value of the contained socket and drop ownership. It will not be closed by the
@@ -82,26 +82,29 @@ class Sock
8282 * send(2) wrapper. Equivalent to `send(this->Get(), data, len, flags);`. Code that uses this
8383 * wrapper can be unit tested if this method is overridden by a mock Sock implementation.
8484 */
85- virtual ssize_t Send (const void * data, size_t len, int flags) const ;
85+ [[nodiscard]] virtual ssize_t Send (const void * data, size_t len, int flags) const ;
8686
8787 /* *
8888 * recv(2) wrapper. Equivalent to `recv(this->Get(), buf, len, flags);`. Code that uses this
8989 * wrapper can be unit tested if this method is overridden by a mock Sock implementation.
9090 */
91- virtual ssize_t Recv (void * buf, size_t len, int flags) const ;
91+ [[nodiscard]] virtual ssize_t Recv (void * buf, size_t len, int flags) const ;
9292
9393 /* *
9494 * connect(2) wrapper. Equivalent to `connect(this->Get(), addr, addrlen)`. Code that uses this
9595 * wrapper can be unit tested if this method is overridden by a mock Sock implementation.
9696 */
97- virtual int Connect (const sockaddr* addr, socklen_t addr_len) const ;
97+ [[nodiscard]] virtual int Connect (const sockaddr* addr, socklen_t addr_len) const ;
9898
9999 /* *
100100 * getsockopt(2) wrapper. Equivalent to
101101 * `getsockopt(this->Get(), level, opt_name, opt_val, opt_len)`. Code that uses this
102102 * wrapper can be unit tested if this method is overridden by a mock Sock implementation.
103103 */
104- virtual int GetSockOpt (int level, int opt_name, void * opt_val, socklen_t * opt_len) const ;
104+ [[nodiscard]] virtual int GetSockOpt (int level,
105+ int opt_name,
106+ void * opt_val,
107+ socklen_t * opt_len) const ;
105108
106109 using Event = uint8_t ;
107110
@@ -124,9 +127,9 @@ class Sock
124127 * value of `true` and `occurred` being set to 0.
125128 * @return true on success and false otherwise
126129 */
127- virtual bool Wait (std::chrono::milliseconds timeout,
128- Event requested,
129- Event* occurred = nullptr ) const ;
130+ [[nodiscard]] virtual bool Wait (std::chrono::milliseconds timeout,
131+ Event requested,
132+ Event* occurred = nullptr ) const ;
130133
131134 /* Higher level, convenience, methods. These may throw. */
132135
@@ -154,17 +157,17 @@ class Sock
154157 * @throws std::runtime_error if the operation cannot be completed. In this case some bytes may
155158 * have been consumed from the socket.
156159 */
157- virtual std::string RecvUntilTerminator (uint8_t terminator,
158- std::chrono::milliseconds timeout,
159- CThreadInterrupt& interrupt,
160- size_t max_data) const ;
160+ [[nodiscard]] virtual std::string RecvUntilTerminator (uint8_t terminator,
161+ std::chrono::milliseconds timeout,
162+ CThreadInterrupt& interrupt,
163+ size_t max_data) const ;
161164
162165 /* *
163166 * Check if still connected.
164167 * @param[out] errmsg The error string, if the socket has been disconnected.
165168 * @return true if connected
166169 */
167- virtual bool IsConnected (std::string& errmsg) const ;
170+ [[nodiscard]] virtual bool IsConnected (std::string& errmsg) const ;
168171
169172protected:
170173 /* *
0 commit comments