diff options
author | crupest <crupest@outlook.com> | 2021-06-06 23:43:52 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-06 23:43:52 +0800 |
commit | 800923717d1f95cd16b270ad8f1e430f77f33f57 (patch) | |
tree | a6370a2a6f1393ba88f25392a702d291dec8a73b /computer-network-experiment/Common.cpp | |
parent | a6088689ec605c97b846fb52beadc0de89fccf76 (diff) | |
download | life-800923717d1f95cd16b270ad8f1e430f77f33f57.tar.gz life-800923717d1f95cd16b270ad8f1e430f77f33f57.tar.bz2 life-800923717d1f95cd16b270ad8f1e430f77f33f57.zip |
...
Diffstat (limited to 'computer-network-experiment/Common.cpp')
-rw-r--r-- | computer-network-experiment/Common.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/computer-network-experiment/Common.cpp b/computer-network-experiment/Common.cpp index 2e01dcb..59c2f0f 100644 --- a/computer-network-experiment/Common.cpp +++ b/computer-network-experiment/Common.cpp @@ -5,6 +5,11 @@ #ifdef WIN32
#include <Windows.h>
#include <winsock.h>
+#else
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <sys/unistd.h>
#endif
[[noreturn]] void PrintErrorMessageAndExit(StringView message,
@@ -46,6 +51,14 @@ void InitWSA() { }
#endif
+int Close(int socket) {
+#ifdef WIN32
+ return closesocket(socket);
+#else
+ return close(socket);
+#endif
+}
+
int main() {
#ifdef WIN32
InitWSA();
|