Remove constness where it makes no sense; Satisfy rule of 5
This commit is contained in:
parent
da346c256e
commit
9aee820625
@ -128,7 +128,7 @@ void NonBlockingServer::disconnect() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
[[nodiscard]] std::expected<std::array<char, 16>, int>
|
[[nodiscard]] std::expected<std::array<char, 16>, int>
|
||||||
NonBlockingServer::get_client_ip_as_string() const {
|
NonBlockingServer::get_client_ip_as_string() {
|
||||||
std::array<char, 16> addrStr;
|
std::array<char, 16> addrStr;
|
||||||
|
|
||||||
if (inet_ntop(AF_INET, &((struct sockaddr_in*)&m_clientAddress)->sin_addr,
|
if (inet_ntop(AF_INET, &((struct sockaddr_in*)&m_clientAddress)->sin_addr,
|
||||||
@ -143,11 +143,11 @@ NonBlockingServer::get_client_ip_as_string() const {
|
|||||||
// return std::unexpected{errno};
|
// return std::unexpected{errno};
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return {addrStr};
|
return addrStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::expected<int, int>
|
[[nodiscard]] std::expected<int, int>
|
||||||
NonBlockingServer::send(std::span<const std::byte> data) const {
|
NonBlockingServer::send(std::span<const std::byte> data) {
|
||||||
const int bytesWritten =
|
const int bytesWritten =
|
||||||
::send(m_clientSocket, (const char*)data.data(), data.size(), 0);
|
::send(m_clientSocket, (const char*)data.data(), data.size(), 0);
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ NonBlockingServer::send(std::span<const std::byte> data) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::expected<int, int>
|
[[nodiscard]] std::expected<int, int>
|
||||||
NonBlockingServer::recv(std::span<std::byte> buffer) const {
|
NonBlockingServer::recv(std::span<std::byte> buffer) {
|
||||||
const int bytesReceived =
|
const int bytesReceived =
|
||||||
::recv(m_clientSocket, (char*)buffer.data(), buffer.size(), 0);
|
::recv(m_clientSocket, (char*)buffer.data(), buffer.size(), 0);
|
||||||
|
|
||||||
|
|||||||
15
src/tcp.hpp
15
src/tcp.hpp
@ -39,6 +39,10 @@ struct ServerSettings {
|
|||||||
class NonBlockingServer {
|
class NonBlockingServer {
|
||||||
public:
|
public:
|
||||||
NonBlockingServer(ServerSettings settings);
|
NonBlockingServer(ServerSettings settings);
|
||||||
|
NonBlockingServer(const NonBlockingServer&) = delete;
|
||||||
|
NonBlockingServer(NonBlockingServer&&) = delete;
|
||||||
|
NonBlockingServer& operator=(const NonBlockingServer&) = delete;
|
||||||
|
NonBlockingServer& operator=(NonBlockingServer&&) = delete;
|
||||||
~NonBlockingServer();
|
~NonBlockingServer();
|
||||||
|
|
||||||
[[nodiscard]] std::expected<void, int> start_listening();
|
[[nodiscard]] std::expected<void, int> start_listening();
|
||||||
@ -48,15 +52,15 @@ public:
|
|||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
[[nodiscard]] std::expected<int, int>
|
[[nodiscard]] std::expected<int, int>
|
||||||
send(std::span<const std::byte> data) const;
|
send(std::span<const std::byte> data);
|
||||||
|
|
||||||
[[nodiscard]] std::expected<int, int>
|
[[nodiscard]] std::expected<int, int>
|
||||||
recv(std::span<std::byte> buffer) const;
|
recv(std::span<std::byte> buffer);
|
||||||
|
|
||||||
bool data_available();
|
bool data_available();
|
||||||
|
|
||||||
[[nodiscard]] std::expected<std::array<char, 16>, int>
|
[[nodiscard]] std::expected<std::array<char, 16>, int>
|
||||||
get_client_ip_as_string() const;
|
get_client_ip_as_string();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ServerSettings m_settings;
|
ServerSettings m_settings;
|
||||||
@ -86,6 +90,11 @@ private:
|
|||||||
|
|
||||||
class NonBlockingClient {
|
class NonBlockingClient {
|
||||||
public:
|
public:
|
||||||
|
NonBlockingClient() = default;
|
||||||
|
NonBlockingClient(const NonBlockingClient&) = delete;
|
||||||
|
NonBlockingClient(NonBlockingClient&&) = delete;
|
||||||
|
NonBlockingClient& operator=(const NonBlockingClient&) = delete;
|
||||||
|
NonBlockingClient& operator=(NonBlockingClient&&) = delete;
|
||||||
~NonBlockingClient();
|
~NonBlockingClient();
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user