aboutsummaryrefslogtreecommitdiff
path: root/computer-network-experiment/Common.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-06-07 14:05:51 +0800
committercrupest <crupest@outlook.com>2021-06-07 14:05:51 +0800
commit6774bcc32ac23728827b36a8c2c2350e811f7940 (patch)
treeee55e8f7ca3ef7c937dd797f863016dfb740e21b /computer-network-experiment/Common.cpp
parent7f2badbf713d37a75df03c1e0704ddab6af06627 (diff)
downloadlife-6774bcc32ac23728827b36a8c2c2350e811f7940.tar.gz
life-6774bcc32ac23728827b36a8c2c2350e811f7940.tar.bz2
life-6774bcc32ac23728827b36a8c2c2350e811f7940.zip
...
Diffstat (limited to 'computer-network-experiment/Common.cpp')
-rw-r--r--computer-network-experiment/Common.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/computer-network-experiment/Common.cpp b/computer-network-experiment/Common.cpp
index 59c2f0f..fbdb2c8 100644
--- a/computer-network-experiment/Common.cpp
+++ b/computer-network-experiment/Common.cpp
@@ -34,9 +34,7 @@
#endif
}
-#ifdef WIN32
- WSACleanup();
-#endif
+ BeforeExit();
std::exit(1);
}
@@ -51,7 +49,7 @@ void InitWSA() {
}
#endif
-int Close(int socket) {
+int CloseSocket(int socket) {
#ifdef WIN32
return closesocket(socket);
#else
@@ -59,16 +57,21 @@ int Close(int socket) {
#endif
}
-int main() {
+void BeforeExit() {
#ifdef WIN32
- InitWSA();
+ WSACleanup();
#endif
- int c = Main();
+ SignalAndWaitForOutputThreadStop();
+}
+int main() {
#ifdef WIN32
- WSACleanup();
+ InitWSA();
#endif
+ int c = Main();
+
+ BeforeExit();
return c;
}