Skip to content

Commit

Permalink
Merge pull request #48 from andreacasalino/WithShutdown
Browse files Browse the repository at this point in the history
shut down method
  • Loading branch information
andreacasalino authored Aug 6, 2024
2 parents c56b62a + d104c6c commit 40fe0ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/header/MinimalSocket/core/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Socket {
*/
bool isBlocking() const { return isBlocking_; }

void shutDown() { resetHandler(); }

protected:
Socket();

Expand Down
12 changes: 4 additions & 8 deletions tests/TestRobustness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ std::string make_repeated_message(const std::string &to_repeat,

static const std::string MESSAGE = "A simple message";

template <typename SocketT> void close(SocketT &subject) {
SocketT{std::move(subject)};
}

struct ThrownOrReceivedNothing {
template <typename Pred> ThrownOrReceivedNothing(Pred pred) {
try {
Expand Down Expand Up @@ -63,7 +59,7 @@ TEST_CASE("Thread safe d'tor tcp case", "[robustness]") {
},
[&client_side = client_side](auto &) {
std::this_thread::sleep_for(std::chrono::milliseconds{200});
close(*client_side);
client_side->shutDown();
});
}

Expand All @@ -75,7 +71,7 @@ TEST_CASE("Thread safe d'tor tcp case", "[robustness]") {
},
[&server_side = server_side](auto &) {
std::this_thread::sleep_for(std::chrono::milliseconds{200});
close(*server_side);
server_side->shutDown();
});
}
}
Expand All @@ -89,7 +85,7 @@ TEST_CASE("Thread safe d'tor tcp case", "[robustness]") {
},
[&server](auto &) {
std::this_thread::sleep_for(std::chrono::milliseconds{50});
close(server);
server.shutDown();
});
}
}
Expand Down Expand Up @@ -154,7 +150,7 @@ TEST_CASE("Thread safe d'tor udp case", "[robustness]") {
},
[&](auto &) {
std::this_thread::sleep_for(std::chrono::milliseconds{200});
close(connection);
connection.shutDown();
});
}

Expand Down

0 comments on commit 40fe0ab

Please sign in to comment.