diff options
author | crupest <crupest@outlook.com> | 2021-06-07 14:05:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-07 14:05:51 +0800 |
commit | da6c0e6194578538ce0bcd1b9815696b96153f6b (patch) | |
tree | bb4121f622161fad8810890e0e16aac8c1826605 /works/life/computer-network-experiment/Common.cpp | |
parent | 2de4663d385ab54c5d8b8adc68611ad67636f56f (diff) | |
download | crupest-da6c0e6194578538ce0bcd1b9815696b96153f6b.tar.gz crupest-da6c0e6194578538ce0bcd1b9815696b96153f6b.tar.bz2 crupest-da6c0e6194578538ce0bcd1b9815696b96153f6b.zip |
import(life): ...
Diffstat (limited to 'works/life/computer-network-experiment/Common.cpp')
-rw-r--r-- | works/life/computer-network-experiment/Common.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/works/life/computer-network-experiment/Common.cpp b/works/life/computer-network-experiment/Common.cpp index 59c2f0f..fbdb2c8 100644 --- a/works/life/computer-network-experiment/Common.cpp +++ b/works/life/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;
}
|