tools/hexnet: Shut down connections when gracefully handling signals

Soda
BodgeMaster 2022-10-23 01:47:44 +02:00
parent 1d7e98d0b3
commit a1ba08b7db
1 changed files with 20 additions and 0 deletions

View File

@ -114,6 +114,26 @@ void signalHandler(int signal) {
tcpSocket.shutdown(SHUT_RD);
}
if (tcpConnector) {
tcpConnector.shutdown(SHUT_RD);
}
if (tcp6Socket) {
tcp6Socket.shutdown(SHUT_RD);
}
if (tcp6Connector) {
tcp6Connector.shutdown(SHUT_RD);
}
if (udpSocket) {
udpSocket.shutdown(SHUT_RD);
}
if (udp6Socket) {
udp6Socket.shutdown(SHUT_RD);
}
std::cerr << "Received signal " << signal << ", bye!" << std::endl;
std::exit(EXIT_SIGNAL);
}