Skip to content

Close weboscket-connections from server-side (C++) #1528

Discussion options

You must be logged in to vote

It's a bit silly but you have to track your connections yourself. Something like this will make it shut down properly (this is an aera that needs improvement - ideally it should be app.close()):

std::unordered_set<void *> connectionSet;

// Track your connections
app.filter([&connectionSet](auto *s, int diff){
if (diff > 0) {
connectionSet.insert((void *) s);
} else {
connectionSet.erase((void *) s);
}
})

// When you want to close:
for (auto *s : connectionSet) {
us_socket_close(SSL, (struct us_socket_t *) s);
}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@fabianskysails
Comment options

Answer selected by uNetworkingAB
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants